我有世界上最簡單的控制器,我想訪問$範圍但它是「未定義的」,我不能,爲我的生活找出原因,然而所有的功能被稱爲corectly, DataService等工作完美,只是我沒有訪問$範圍?!
控制器代碼如下
app = angular.module("windscreens", []);
app.controller('DamageCtrl', function($scope, DataService) {
$scope.setDamageLocation = function(location) {
DataService.getDamage().setLocation(location);
};
$scope.isLocation = function(requiredLocation) {
return DataService.getDamage().getLocation() === requiredLocation;
};
$scope.progress = function() {
};
});
如何聲明DataService'工作時'$ scope'未定義?你的代碼在哪裏出錯? – Bart
現在還沒有錯誤,我想弄清楚如何讓函數「progress」工作,然後去看看「$ scope」是什麼,並得到了未定義 - 數據服務在前端工作,什麼觸發setLocation,並消耗isLocation正在按預期工作100% – DrogoNevets
您是如何*在「$ scope」查看*的。我認爲你的問題在於此。 – Bart