我试图用angularjs引用模型时遇到了问题。我可以让他们中的一些人参考,但其他人不工作。我已经包含下面的代码:AngularJS范围
function DeleteCustomers($scope, func) {
$scope.delete = function() {
func.deleteCustomer($scope.customer);
}
}
function UpdateCustomers($scope, func) {
$scope.update = function() {
func.updateCustomer({ name: $scope.name2, telephone: $scope.telephone2,
email: $scope.email2, street: $scope.street2,
city: $scope.city2, zipcode: $scope.zipcode2 });
}
}
}
和HTML是
<div ng-controller="UpdateCustomers">
<form class="test-angular-update">
<input type="text" ng-model="name2"><br>
<input type="text" ng-model="telephone2"><br>
<input type="text" ng-model="email2"><br>
<input type="text" ng-model="street2"><br>
<input type="text" ng-model="city2"><br>
<input type="text" ng-model="zipcode2"><br>
<button class="button" ng-click="update()">Update</button><br>
</form>
</div>
<br><br>
<div ng-controller="DeleteCustomers">
<form class="text-angular-delete">
Customer Name <input type="text" ng-model="customer"><br>
<button class="button" ng-click="delete()">Delete</button><br>
</form>
</div>
所有车型从UpdateCustomers和DeleteCustomers不能够由控制器引用。任何帮助,将不胜感激。
谢谢!
这不是很清楚你的问题是什么,你的代码太不完整做出猜测。你能否提供一个更好的演示问题的jsFiddle? – 2013-02-23 07:17:41
问题是UpdateCustomers和DeleteCustomers下的ng模型没有被解析。因此,我无法像使用其他模型一样通过$ scope访问它们。 – user2101411 2013-02-23 13:34:26