現在我們所面臨的問題在調用對DataService(解析)控制器調用,問題是,這個代碼不工作:
function MainCtrl($scope, DataService, $location)
{
$scope.actionList = function() {
// Call the service and fetch the list of signatures that match the given action ID
DataService.getActions(function (results) {
$scope.$apply(function() {
// Apply the results to the signatureList model so it will refresh the table in the view
$scope.actionList = results;
});
});
};
}
我把一個斷點DataService的線,但它並沒有撞到,但如果我用這種方式實現按Ctrl它得到調用和它的作品!:
function MainCtrl($scope, DataService, $location)
{
// Call the service and fetch the list of signatures that match the given action ID
DataService.getActions(function (results) {
$scope.$apply(function() {
// Apply the results to the signatureList model so it will refresh the table in the view
$scope.actionList = results;
});
});
}
任何想法,爲什麼會這樣?
除此之外,一旦在工作(與第二實現)我想顯示活動的屬性,如果我試圖讓這樣的屬性它不工作:
<div id="wrapper"><div id="scroller">
<div ng-controller="MainCtrl">
<ul id="thelist">
<li ng-repeat="action in actionList">{{action.get('Action')}}</li>
</ul>
</div>
</div></div>
但如果我嘗試獲取像{{action}}這樣的整個對象,我可以看到所有條目。
任何錯誤在控制檯 – 2013-03-23 11:21:18
我看到的第一個問題是兩種功能:和數組被命名爲因爲'DataList'是角應用程序的一部分時'actionList' – 2013-03-23 11:26:13
不應該使用'$ .apply'。標記中的{{action.get()}}'沒有意義。爲什麼從'DataService'返回的數組中的對象在其中具有函數...或者它們是做什麼的?在ng-repeat標記中只需要{{Action}}。顯示'DataService'模塊或工廠的代碼 – charlietfl 2013-03-23 13:53:50