以下是我的代码。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