I used route resolve to prevent loading view before executing some functions, then I read here Error: Unknown provider: employeesProvider <- employees that I have to remove ng-controller
, then I did
<div > <!-- ng-controller="navBar" has removed from here -->
<div ng-include="'...../partitials/navBar.html'"></div>
</div>
here is the route provider
$routeProvider
.when("/ERPdocumentation/", {
templateUrl : function(params){
// code here
return template
},
controller: "navBar",
resolve: {
filteredModules: function (searchForService) {
return searchForService.getfilteredModules();
}
}
});
But, that made some functions no longer worked in navBar
controller, for example, when I click this button:
<md-button ng-click="routeToSearchPage (searchString)">
, the functions doesn't works in the navBar
controller:
angular.module("myApp")
.controller("navBar", function ($scope,filteredModules, $location) {
$scope.filteredModules = filteredModules;
$scope.routeToSearchPage = function(searchString){
console.log("route") // nothing happened here
$location.search("search", searchString);
$location.path($location.$$path);
};
})
.factory("searchForService", function(){
return {
getfilteredModules: function(){
// code here to get search results
}
}
})
https://jsfiddle.net/e1vfrcrf/14/ Do i misunderstand something with those concepts?What caused this problem? and how to solve it?