AngularJS: functions doesn't work when setting route resolve and removing ng-controller directive -


i used route resolve prevent loading view before executing functions, read here error: unknown provider: employeesprovider <- employees have remove ng-controller, did

<div > <!-- ng-controller="navbar" has removed here -->     <div ng-include="'...../partitials/navbar.html'"></div> </div> 

here route provider

$routeprovider .when("/erpdocumentation/", {             templateurl : function(params){                 // code here                 return template              },             controller: "navbar",             resolve: {                 filteredmodules: function (searchforservice) {                    return searchforservice.getfilteredmodules();                 }             }         }); 

but, made functions no longer worked in navbar controller, example, when click button:

<md-button ng-click="routetosearchpage (searchstring)"> 

, functions doesn't works in 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 search results          }    }  }) 

https://jsfiddle.net/e1vfrcrf/14/ misunderstand concepts?what caused problem? , how solve it?

well, solution tried not use route resolve @ all, i's return search results service directly, way:

        $scope.filteredmodules = searchforservice.getfilteredmodules(); 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -