AngularJs provider is not defined when using yeoman template -
source: http://plnkr.co/edit/npytspwsy3rh0bzl9juq
the code example works on plnkr. when copy code new app created yeoman following error:
referenceerror: $hello not defined @ $get (http://localhost:9000/scripts/app.js:21:16) @ object.invoke (http://localhost:9000/components/angular/angular.js:2864:28) @ http://localhost:9000/components/angular/angular.js:2702:37 @ getservice (http://localhost:9000/components/angular/angular.js:2824:39) @ object.invoke (http://localhost:9000/components/angular/angular.js:2842:13) @ http://localhost:9000/components/angular/angular.js:2702:37 @ object.getservice [as get] (http://localhost:9000/components/angular/angular.js:2824:39) @ http://localhost:9000/components/angular/angular.js:9545:24 @ filter (http://localhost:9000/components/angular/angular.js:6107:14) @ _filterchain (http://localhost:9000/components/angular/angular.js:6098:41)
i can't find out why works on plnkr doesn't work freshly created angular app.
the yeoman app looks this:
'use strict'; angular.module('asdfapp', ['myhello']) .config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'views/main.html', controller: 'mainctrl' }) .otherwise({ redirectto: '/' }); }); var mymodule = angular.module('myhello', []); mymodule.provider('$hello', function () { this.$get = function () { $hello = function (key) { return 'hello ' + key; }; return $hello; } }); mymodule.filter('hello',function ($parse, $hello) { return function (key) { return $hello(key); }; });
and works in yeoman scaffolded app when change code (return function in object):
var mymodule = angular.module('myhello', []); mymodule.provider('$hello', function () { this.$get = function () { var = function (key) { return 'hello ' + key; }; return { : say}; } }); mymodule.filter('hello',function ($parse, $hello) { return function (key) { return $hello.say(key); }; });
Comments
Post a Comment