Angularjs $scope变量未重新加载
在控制器中,我有以下代码:Angularjs $scope变量未重新加载,angularjs,asp.net-web-api,data-binding,angularjs-bindings,Angularjs,Asp.net Web Api,Data Binding,Angularjs Bindings,在控制器中,我有以下代码: //View <input type="text" value="{{customer.lastName}}" /> //Controller $scope.getbycode = function (customerCode) { var deferred = $q.defer(), getCustomerRequest = { code: customerCode }; $ht
//View
<input type="text" value="{{customer.lastName}}" />
//Controller
$scope.getbycode = function (customerCode) {
var deferred = $q.defer(),
getCustomerRequest = {
code: customerCode
};
$http({ method: 'POST', url: 'api/customer/getbycode', data: getCustomerRequest })
.success(function (data) {
deferred.resolve(data);
}).error(function () {
deferred.reject();
});
return deferred.promise;
};
$scope.getbycode($routeParams.customerCode).then(function (data) {
$scope.customer = data.customer;
});
我更改输入中的文本,然后单击超链接。
调用WEBAPI时,reload
函数中返回的数据正确,但视图未更新
我遗漏了什么?value=“{{customer.lastName}}”
只会第一次计算表达式,然后用customer.lastName
值替换为1
,DOM如下所示
<input type="text" value="1" />
value=“{{customer.lastName}}”
只会第一次计算表达式,然后用customer.lastName
值替换为1
,DOM如下所示
<input type="text" value="1" />
<input type="text" ng-model="customer.lastName" />