gpt4 book ai didi

javascript - Angular ng-model 语法不起作用

转载 作者:行者123 更新时间:2023-12-03 08:25:46 27 4
gpt4 key购买 nike

首先,我一直在尝试复制 jsfiddle 的这段摘录:http://jsfiddle.net/PQvQ2/1245/每当我尝试在代码中添加 ng-model=selection.ids[catagory.id] 时,它都会抛出 Va(...) 未定义的错误。

这是我的代码`

<form ng-controller="formController">
<div class="form-group">
<tr ng-repeat="table in districtArray" id="rowId-{{table.schoolId}}" class="unselected-row">
<td>

<label class="table-center-align table-checkbox-label box-unchecked" for="{{table.schoolId}}">
<input class="table-checkbox box-unchecked" type="checkbox" ng-model="checkboxData.Id[table.schoolId]" id="{{table.schoolId}}">
<span ng-click="updateSelection(table.schoolId)"></span>
</label>

</td>
</tr>
</div>
</form>`

这让我抓狂,为什么这不起作用。 Controller 被放置在模板内并在范围内传递。

app.controller('distDashController', function($scope,$http,$timeout,$routeParams,adminDataCache) {
....
function formController($scope){
$scope.checkboxData.Id=$scope.table.schoolId;
$scope.checkboxData.checked = checked;

};

我只是希望 checkboxData 中的愚蠢数据如下所示:

{
“table.schoolId”: bool 值,
“table.schoolId”: bool 值
}

请问,为什么这不起作用?!?!

最佳答案

您在另一个具有不同名称的 Controller 中声明了您的函数,因此它在 jsfiddle 示例中无法按预期工作。请使用 Angular Controller 而不是简单的函数。例如see this

app.controller('formController', function ($scope) {
// your code
}

关于javascript - Angular ng-model 语法不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33560008/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com