0
我想摆脱角度添加到您的模型值的$$ hashKey值。根据大多数实施赛道的消息来源应该解决这个问题,但我做错了什么。
vm.productTypes是id属性为GUID的任何对象数组。
得到的模型值...
$$hashKey: "object:445"
id: "9e695340-d10a-40ca-9cff-e9a93388912a"
name: "Medical"
type: 1
typeString: "ProductTypes"
HTML代码:
<md-select id="type" ng-model="vm.currentProduct.productType" name="type"
ng-model-options="{trackBy: '$value.id'}"
required>
<md-option ng-repeat="pt in vm.productTypes track by pt.id" ng-value="pt">
{{pt.name}}
</md-option>
</md-select>
我要去哪里错了?
更新:
似乎name属性是造成这种奇怪的行为。错误? http://codepen.io/anon/pen/LNpMYJ
由于您使用ng-repeat默认情况下会为其添加$$ hashKey。如果我们需要删除它,我们可以使用$ index或id或任何键的轨迹, – 2016-03-05 19:27:45
我已经通过id属性进行跟踪。看看我的评论,似乎当名称属性在md-select上时,它仍然会添加一个$$ hashKey。你的回答并不真正给出任何新的信息,为什么name属性导致这种行为。 – Tersius
嗨好友,当我运行代码笔链接给出上面显示我的错误消息,“SyntaxError:缺少;语句前 angular-material.js:1:4 错误:[$ injector:modulerr]无法实例化模块MyApp应付到: [$ injector:modulerr]由于以下原因,无法实例化模块ngMaterial: [$ injector:nomod]模块'ngMaterial'不可用!模块名称拼写错误或忘记加载模块名称如果注册模块确保您指定依赖关系作为第二个参数。 http://errors.angularjs.org/1.4.8/$injector/nomod?p0=ngMaterial minErr loadModules/<@https:// ajax。 – 2016-03-06 07:06:24