Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/433.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在angularjs中声明多个服务依赖项_Javascript_Angularjs_Angular Services - Fatal编程技术网

Javascript 在angularjs中声明多个服务依赖项

Javascript 在angularjs中声明多个服务依赖项,javascript,angularjs,angular-services,Javascript,Angularjs,Angular Services,我在控制器中声明了对2个服务的依赖,如下所示: var app = angular.module('app', ['ngDropdowns']); app.controller('InventoryCaptureCtrl', ['$scope', 'DataStoreService','VMInterfaceService', function($scope, DataStoreService, VMInterfaceService) {..} 但是它在上面的声明

我在控制器中声明了对2个服务的依赖,如下所示:

var app = angular.module('app', ['ngDropdowns']);  


app.controller('InventoryCaptureCtrl', 
     ['$scope', 'DataStoreService','VMInterfaceService',
     function($scope, DataStoreService, VMInterfaceService) {..}
但是它在上面的声明中抛出了我-
未捕获的SyntaxError:Unexpected-token函数。有什么问题

这是我的complte JS:

 var app = angular.module('app', ['ngDropdowns']);  

  app.controller('InventoryCaptureCtrl', ['$scope', 'DataStoreService','VMInterfaceService',
    function($scope, DataStoreService, VMInterfaceService) {

// By default the 'text' property will be used as the display text in the dropdown entry.
// All options that are not dividers must have a 'text' property.
// Or you can specify a different property name via the dropdown-item-label attribute.
//
// If an options object has an 'href' property set, then that dropdown entry
//   will behave as a link and cannot be selected.
$scope.ddSelectOptions = [{
  text: 'Option1',
  iconCls: 'someicon'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, ];

$scope.ddSelectOptionsType = [{
  text: 'Option1',
  iconCls: 'someicon'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, {
  text: 'Option2',
  someprop: 'somevalue'
}, ];

$scope.ddSelectSelected = {
  "text": "Select a Category"
}; // Must be an object
$scope.ddSelectSelectedType = {
  "text": "Select a Type"
}; // Must be an object

DataStoreService.initService();
$scope.items = DataStoreService.list();
console.log($scope.items);

var original = {
    itemCategory:null,itemName:null,
    itemPrice:null,purchaseDate:null,applianceType:null,
    insStatus:null,id:null
};
$scope.newitem = angular.copy(original);

$scope.saveItem = function() {
  alert("add new");
  $scope.newitem.itemCategory = $scope.ddSelectSelected.text;
  $scope.newitem.applianceType = $scope.ddSelectSelectedType.text;
  DataStoreService.save($scope.newitem);
  //$scope.newitem = {};
}

$scope.calculateScore = function(){
  alert("calculateScore" + id);
  VMInterfaceService.calculateScore(id);
}

$scope.delete = function(id) {
  alert(id);
  DataStoreService.delete(id);
  if ($scope.newitem.id == id) $scope.newitem = {};
}

$scope.edit = function(id) {
  $scope.newitem = angular.copy(DataStoreService.get(id));
}
  }
  ]);
应该是:

app.controller('InventoryCaptureCtrl', 
    ['$scope', 'DataStoreService','VMInterfaceService',
    function($scope, DataStoreService, VMInterfaceService) {..

}]); // => '}' close function, ']' close array and ')' close method call

是否使用“;”关闭控制器?我在这里添加了plnkr: