In controller I have followed methods:
var isPaused = false;
$scope.switcher = function (booleanExpr, trueValue, falseValue) {
return booleanExpr ? trueValue : falseValue;
};
$scope.isPaused = function () {
return isPaused;
};
And I can call it from HTML like:
<body ng-controller="Cntrl">
...
<h4>
{{ switcher( isPaused(), 'Search Address Mode', 'Search Location Mode' )}}
</h4>
<div class="btn-group">
...
</div>
As you see if isPaused() returns false I get <h4>Search Location Mode</h4>
This is utility therefore I want to define it as factory
feederliteModule.factory('switcher', function () {
return {
sw: function (booleanExpr, trueValue, falseValue) {
return booleanExpr ? trueValue : falseValue;
}
};
});
No exceptions but
when I try to call it like:
<h4>
{{ switcher.sw( isPaused(), 'Search Address Mode', 'Search Location Mode' )}}
</h4>
<div class="btn-group">
...
</div>
Nothing happens.
**I added 'switcher' to controller.
How can I call factory method from HTML?
(*You welcome to change/edit my question if it seems not clear)
Thank you,