error if minimized , loaded in same file. if app.ts loaded before service or directive works.
(no problems controllers)
how can make work?
console error:
site.js:119 error: [$injector:unpr] http://errors.angularjs.org/1.5.0/$injector/unpr?p0=eprovider%20%3c-%20e%20%3c-%20routenavigation%20%3c-%20navigationdirective @ error (native) @ http://localhost:50308/js/site.js:11:416 @ http://localhost:50308/js/site.js:48:7 @ object.d [as get] (http://localhost:50308/js/site.js:45:270) @ http://localhost:50308/js/site.js:48:69 @ d (http://localhost:50308/js/site.js:45:270) @ e (http://localhost:50308/js/site.js:46:1) @ object.invoke (http://localhost:50308/js/site.js:46:86) @ object.$get (http://localhost:50308/js/site.js:43:460) @ object.invoke (http://localhost:50308/js/site.js:46:295)(anonymous function) @ site.js:119
angularjs error message:
unknown provider: eprovider <- e <- routenavigation <- navigationdirective
app.ts
enter code here "use strict"; var app = angular.module('houseconcertapp', ['ngcookies', 'pascalprecht.translate', 'ngroute', 'houseconcertcontrollers', 'houseconcertservices', 'houseconcertdirectives']); app.config([ '$translateprovider', '$routeprovider', function($translateprovider, $routeprovider) { ....
services.ts
var houseconcertservices = angular.module('houseconcertservices', []); houseconcertservices.factory('routenavigation', function ($route, $location) { var routes = []; angular.foreach($route.routes, function (route, path) { if (route.name) { routes.push({ path: path, name: route.name }); } }); return { routes: routes, activeroute: function (route) { return route.path === $location.path(); } }; });
directives.ts
var houseconcertdirectives = angular.module("houseconcertdirectives", []); houseconcertdirectives.directive('navigation', ['routenavigation', routenavigation => ({ restrict: "e", templateurl: "navigation-directive-tpl.html", controller($scope) { $scope.routes = routenavigation.routes; $scope.activeroute = routenavigation.activeroute; } })]);
index.html
<!doctype html> <html ng-app="houseconcertapp"> <head> <base href="/index.html"> <title>house concert</title> <meta charset="utf-8"/> <meta http-equiv="x-ua-compatible" content="ie=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="css/main.css"/> <script src="js/site.js" onload="hc.common.initialize()"></script> </head> <body> <navigation></navigation> <div ng-controller="houseconcertctrl"> <div ng-view></div> </div> </div> </body> </html>
it works if html head script includes this: not if in order minimized in site.js (with gulp)
<script src="pathtofolder/app.ts"></script> <script src="pathtofolder/services.ts"></script> <script src="pathtofolder/controllers.ts"></script> <script src="pathtofolder/directives.ts"></script>
to files minified
without error should make sure follow dependency injection pattern consistently. routenavigation
factory code missing di inline array annotation in code.
change below
houseconcertservices.factory('routenavigation', function ($route, $location) {
to
houseconcertservices.factory('routenavigation',['$route', '$location', function ($route, $location) { //service code is. }]);
doc link minification related warning
Comments
Post a Comment