Why angular can't deal with NaN value passed to directive?

314 views
Skip to first unread message

Artur Nowakowski

unread,
Jun 19, 2014, 6:22:47 AM6/19/14
to ang...@googlegroups.com
I've tried to answer the question on stackoverflow (http://stackoverflow.com/questions/24271524/angular-js-nan-handling) and I've seen strange behavior of angular directive when NaN value is passed to directive's scope. I can't explain why does it happen, so maybe you could explain it to me. 

It's the directive code:

.directive('test',function(){
    return{
        restrict: 'E',
        template: '<span>Test directive number = {{number}}</span>',
        scope: {
            number: '='    
        },
        link: function(scope,elem,attrs){            
           scope.number = scope.number || 10;
        }
    }
});

If I pass NaN as number attribute, link function cannot manipulate with "scope.number" variable. If I try to change its value even by simply "scope.number = 5", nothing happens. 
Is it a bug in angular or an expected behavior? Why does it happen?

raju reddy

unread,
Jun 19, 2014, 8:16:28 AM6/19/14
to ang...@googlegroups.com
Hi,

 Hope you restricted to element,Can you change and try it

 
Reply all
Reply to author
Forward
0 new messages