以下是我的代碼。2路綁定不能按預期工作。能否請您點時的錯誤角度2路綁定不起作用
<div id="list" class="form-group">
<label for="attach" class="col-xs-2 control-label">{{ resource["gve.common.attach"] }}</label>
<div class="col-xs-5">
<ol class="marTop10">
<li class="exactFit" ng-repeat="files in attachList">{{ files.fileName }}</li>
</ol>
</div>
</div>
$scope.populateView = function()
{
$rootScope.inputSpin = false;
$rootScope.modifiedCaseData = $scope.problem;
$scope.showReviewBtn = $rootScope.showReviewBtn;
$scope.attachList = [];
$scope.attachList.push({fileId:"100",fileName:"Test.pdf"});
for(i in $scope.attachList) {
console.log (i, $scope.attachList[i]);
}
};
文件名是沒有得到顯示HTML {{files.fileName}},即使{FILEID:「100」,文件名:「檢驗.pdf」}被添加到$ scope.attachList
編輯1:我很抱歉沒有提到這些細節。 ng-controller已被定義,並且populateView()從另一個函數中被調用。
編輯2:從console.log。
09:56:17.486 problemCtrl.js?gccm=1.0:185 0 Object {fileId: 100, fileName: "untitled 8.txt"}fileId: 100fileName: "untitled 8.txt"
我沒有看到NG-控制器或NG-應用。我希望這一部分已經涵蓋。除此之外,'$ scope.attachList'在'$ scope.populateView'函數內被賦值,但是我沒有看到它在任何地方被調用。 – sisyphus
在函數內部調用'console.log',調用'populateView'後調用它來驗證設置的值。 – sisyphus
嗨,這裏是從console.log 09:56:17.486 problemCtrl.js?gccm = 1.0:185 0對象{fileId:100,fileName:「untitled 8.txt」} fileId:100fileName:「untitled 8.txt 「....我不確定爲什麼雙向綁定不會發生在這種情況下 – Sheetal