Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/sql-server-2008/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 动态Ng模型名称_Angularjs_Angular Ngmodel - Fatal编程技术网

Angularjs 动态Ng模型名称

Angularjs 动态Ng模型名称,angularjs,angular-ngmodel,Angularjs,Angular Ngmodel,我正在动态创建文本框,因此我还需要动态模型名,我想我应该使用它的Id,因为它是相同的 我有这个文本框: <input type="text" ng-init="scope[child.Root.Id] = ''" ng-model="scope[child.Root.Id]" /> 文本框应该绑定到Child.Root.Id的值,这似乎是可行的,因为以下示例工作得非常好: <p ng-hide="scope[child.Root.Id] == 123">This i

我正在动态创建文本框,因此我还需要动态模型名,我想我应该使用它的Id,因为它是相同的

我有这个文本框:

<input type="text" ng-init="scope[child.Root.Id] = ''" ng-model="scope[child.Root.Id]" />

文本框应该绑定到Child.Root.Id的值,这似乎是可行的,因为以下示例工作得非常好:

<p ng-hide="scope[child.Root.Id] == 123">This is a test.</p>
<p ng-hide="scope[child.Root.QuestionModel.ItemId] == 123">This is a test.</p>
这是一个测试

这是一个测试

这两个Id具有相同的值。当在文本框中键入“123”时,文本将隐藏

但是,我需要隐藏其他内容,在这里我不能使用child.Root.id,但我确实有一个具有相同值的child.Root.ParentId:

<p ng-hide="scope[child.Root.ParentId] == 123">This is also a Test!</p>
这也是一个测试

这不行,我做错了什么

这是我在Angular的第一个项目,所以我没有太多的经验

提前谢谢

编辑:


@*启动myApp html*@
@Html.Partial(“QuestionEntryPartialView”)
这也是一个测试

@**@ @*结束myApp*@ var-app=angular.module('myApp',[]); app.controller('ctrl',函数($scope,$http,$sce){ window.MY_SCOPE=$SCOPE; $http.post('@Url.Action(“GetItemsModel”,“Question”)) .成功(功能(响应){ $scope.model=响应; 控制台日志(响应); }); });
QuestionEntrypartialView包含:

<div>
    <input type="text" ng-init="scope[child.Root.Id] = ''" ng-model="scope[child.Root.Id]"/>
</div>
<p ng-hide="scope[child.Root.Id] == 123">This is a test.</p>
<p ng-hide="scope[child.Root.QuestionModel.ItemId] == 123">This is a test.</p>

这是一个测试

这是一个测试


你能把完整的代码放在一起吗?可能的重复的确是一个类似的问题,但不一样;他的回答也帮不了我。
<div>
    <input type="text" ng-init="scope[child.Root.Id] = ''" ng-model="scope[child.Root.Id]"/>
</div>
<p ng-hide="scope[child.Root.Id] == 123">This is a test.</p>
<p ng-hide="scope[child.Root.QuestionModel.ItemId] == 123">This is a test.</p>