AngularJSを使い始めたばかりです 次のコードはコンソールにエラーを表示します。
不明なプロバイダ:$ scopeProvider < - $ scope < - newActiveOrdersModel。私は調査しましたが、Unknown Providerのエラーはさまざまな理由で発生する可能性があります。誰かが間違っている場所を指摘できればいいですね。
var app;
(function(angular){
app = angular.module('OrdersDashboard',[]);
app.config(['$routeProvider', function($routeProvider) {
$routeProvider.
when('/current/new', {templateUrl: 'orders/partials/new_current', controller: 'newActiveOrdersCtrl'}).
otherwise({redirectTo: '/'});
}]);
app.service('newActiveOrdersModel', ['$scope', '$rootScope',
function($scope, $rootScope){
this.Orders=["This is a test order"];
this.fetchOrders = function(){
console.log("This is a test order");
this.Orders=["This is a test order1111"];
};
}]);
app.controller('newActiveOrdersCtrl', ['$scope', '$rootScope', 'newActiveOrdersModel',
function($scope, $rootScope, newActiveOrdersModel){
$scope.test="Hello World";
}]);
})(angular);
Angular Jsは "newActiveOrdersModel"を認識できないようです。
サービスに '$ scope 'を挿入することはできません。シングルトン$スコープのようなものはありません。あなたのコードがそれを何も使っていないように見せているのはなぜなのでしょうか。 –