AngularJS控制器“;作为「;操作人员
我在AngularJS中有这样的观点:AngularJS控制器“;作为「;操作人员,angularjs,controller,Angularjs,Controller,我在AngularJS中有这样的观点: <form ng-submit="addCust.submit();" ng-controller="AddCustomerCtrl as addCust"> <div> <input type="text" ng-model="addCust.cName" required /> </div> <div> <input type="text" ng-model="addC
<form ng-submit="addCust.submit();" ng-controller="AddCustomerCtrl as addCust">
<div>
<input type="text" ng-model="addCust.cName" required />
</div>
<div>
<input type="text" ng-model="addCust.cCity" required />
</div>
<div>
<button type="submit">Add Customer</button>
</div>
但是“as”操作符在我的netbeans中不起作用
我的目标是将多个控制器附加到一个元素,因此我不想更改控制器本身的名称,而是根据需要在视图中将控制器附加到元素。
谁能帮我找出哪里不对吗?
非常感谢。将控制器修改为:
helloWorldControllers.controller('AddCustomerCtrl',['$location', function AddCustomerCtrl($location){
var addCust = this;
addCust.submit = function(){ $location.path('/addedCustomer/' + addCust.cName + "/" + addCust.cCity); }; } ]);
谢谢,您的回答是正确的,但我的目标是将多个控制器附加到一个元素,因此我不想更改控制器本身的名称,而是根据需要在视图中将控制器附加到元素。
helloWorldControllers.controller('AddCustomerCtrl',['$location', function AddCustomerCtrl($location){
var addCust = this;
addCust.submit = function(){ $location.path('/addedCustomer/' + addCust.cName + "/" + addCust.cCity); }; } ]);