JSFiddle - React, Tailwind, and code Playground
by Artur Nowakowski
HTML
<div ng-app="app" ng-controller="ctrl">
<h3>ctrl:</h3>
<p>not NaN variable = {{notNanVariable}}</p>
<p>NaN variable = {{nanVariable}}</p>
<hr/>
<h3>Directive:</h3>
<p><test number="notNanVariable"></test></p>
<p><test number="nanVariable"></test></p>
</div>
JavaScript
var app=angular.module('app',[])
.controller('ctrl',function($scope){
$scope.notNanVariable = 4;
$scope.nanVariable = NaN;
})
.directive('test',function(){
return{
restrict: 'E',
template: '<span>Test directive number = {{number}}, model: {{model}}</span>',
scope: {
number: '='
},
link: function(scope,elem,attrs){
scope.number = scope.number || 10;
scope.model = scope.number || 10;
}
}
});