1
我跑在NG-點擊此功能,但得到了一個錯誤類型錯誤:未定義是不是在這條線的功能:$scope.$apply(function() {
app.controller('MainControl', function($scope, $http){
$scope.add = function(){
$http({
url: "php/insert.php",
method: "POST",
data: {
'myId': myId
},
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
}
}).success(function (data, status, headers, config) {
$scope.$apply(function() {
$scope.currentId = data;
});
}).error(function (data, status, headers, config) {});
$scope.tabs.push({
"currentId": $scope.currentId
});
}
});
爲什麼要使用$範圍移動
到
success
回調的HTTP承諾。$申請的權利呢?這是沒有必要的。 –