In controller
I have followed methods:
var isPaused = false;
$scope.switcher = function (booleanExpr, trueValue, falseValue) {
return boo
Using AngularJS 1.7.2 and Page Controller (Every Webpage has it's own controller)
First take the Factory view:
AppName.factory('eventMate', function() {
let obj = this;
obj.search = "";
obj.setSearchValue = function(value) {
obj.search = value;
return obj.search;
};
obj.getSearchValue = function() {
return obj.search;
};
return obj;
});
In one of the child Controller, named rfcController
AppName.controller("rfcController", function ($scope, $http, $filter, $window, $location, $anchorScroll,
textMate, datetimeMate, restpack, pagination, imageMate, eventMate) {
//there are many more service providers and injectors also, just showing for an idea
$scope.eventMate = eventMate;
$scope.getFiltered = function(){
let searchValue = $scope.eventMate.getSearchValue().toString();
if(searchValue === undefined){
return "";
} else {
return searchValue.toString();
}
};
}
Now see the source through html side, where I will call this method.
<table>
<tr class="rfc_table_td_tr" ng-repeat="(key, value) in rfcDetails | filter:getFiltered()">
<td>{{value.createdDate}}</td>
<td>{{value.rfcTitle}}</td>
<td>{{value.rfcDetails}}</td>
</tr>
</table>
Hope it will help many one. :D
Well, you're not really supposed to do that... but what you can do is put your service object in a property on your $scope, and call it from there.
app.controller('MyCtrl', function($scope, switcher) {
$scope.switcher = switcher;
});
I had a more general question, "How to call angularjs scope/factory/service from html on page load." My solution was to call the method within ng-show.
<div ng-show="runThisMethod(someVarOnScope)" .....>