Reach a value provider from HTML

62 views Asked by At

How can I reach a value from a module in my HTML? Like module.value("myvalue", true) and in HTML <div ng-show="myvalue">Hello</div>.

Edit

OK, one solution was to change the value to an object instead of a primitive, like this: module.value("myvalue", {value: true}) and <div ng-show="myvalue.value">Hello</div> and then include in the controller $scope.myvalue = myvalue and inject myvalue in the argument list of the controller.

1

There are 1 answers

0
Michael Kang On

If myvalue is a primitive type, then you should use a constant:

module.constant('myvalue', true);

myvalue is then injectable:

module.controller('controller', function(myvalue) {
});