Reputation: 184
I have defined the following constants in my app module
angular.module("Test", [])
.constants("CONST", {
CONSTANT: "myConstant"
})
.controller("TestCtrl" ['CONST', function(const){
$scope.testConst = function(myConst){
if(myConst == CONST.CONSTANT){
return true;
}else{
return false;
}
}
}]);
In my html code i have
<p ng-if="testConst(CONST.CONSTANT)"/>
When i debug my method i see that myConst variable is undefined. How can i pass the constant variable as parameter in the Html code.
Upvotes: 0
Views: 2024
Reputation: 28750
You'll have to add it to the scope. As constants aren't available to the dom.
.controller("TestCtrl" ['CONST', function(CONST){
$scope.CONST = CONST;
$scope.testConst = function(myConst){
if(myConst == CONST.CONSTANT){
return true;
}else{
return false;
}
}
}]);
Upvotes: 1