我按照这个例子http://jsfiddle.net/simpulton/XqDxG/,也可以在这里找到http://youtu.be/1OALSkJGsRw
var myModule = angular.module('myModule', []);
myModule.factory('mySharedService', function($rootScope) {
var sharedService = {};
sharedService.message = '';
sharedService.prepForBroadcast = function(msg) {
this.message = msg;
this.broadcastItem();
};
sharedService.broadcastItem = function() {
$rootScope.$broadcast('handleBroadcast');
};
return sharedService;
});
Run Code Online (Sandbox Code Playgroud)
总是得到这个消息后
错误:未知提供者:sharedServiceProvider < - sharedService
我只是复制了jsfiddle的代码.我很惊讶 同样的错误.疯狂,导致jsfiddle代码工作完美.
这段代码可以弃用吗?