相关疑难解决方法(0)

Angularjs ng-model在ng-if中不起作用

这是显示问题的小提琴.http://jsfiddle.net/Erk4V/1/

如果我在ng-if中有ng模型,则该模型似乎不能按预期工作.

我想知道这是一个错误还是我误解了正确的用法.

<div ng-app >
    <div ng-controller="main">

        Test A: {{testa}}<br />
        Test B: {{testb}}<br />
        Test C: {{testc}}<br />

        <div>
            testa (without ng-if): <input type="checkbox" ng-model="testa" />
        </div>
        <div ng-if="!testa">
            testb (with ng-if): <input type="checkbox" ng-model="testb" />
        </div>
        <div ng-if="!someothervar">
            testc (with ng-if): <input type="checkbox" ng-model="testc" />
        </div>

    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

angularjs

201
推荐指数
4
解决办法
10万
查看次数

标签 统计

angularjs ×1