I have a boolean variable in my cshtml file. When I try to pass it to my Angular directive, it is received as "False" instead of "false". If I hardcode it to "false" (lower case), it does not work either.
My cshtml file:
@{
var myVar = false;
}
<some-directive test="@myVar"></some-directive>
My test directive is like this:
angular.module('someApp')
.directive('someDirective', function () {
return {
restrict: 'E',
scope: {
test: '@'
},
link: function ($scope, element, attrs) {
console.log($scope.test) // False
console.log(!$scope.test) // false
console.log(!!$scope.test) // true
}
}
});