Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.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 Angular js双向数据绑定问题管理“;文本框“;至;标签";改变_Angularjs_Angularjs Scope - Fatal编程技术网

Angularjs Angular js双向数据绑定问题管理“;文本框“;至;标签";改变

Angularjs Angular js双向数据绑定问题管理“;文本框“;至;标签";改变,angularjs,angularjs-scope,Angularjs,Angularjs Scope,我使用的数据模型有“编辑”字段。根据“编辑”值,我使用文本框或标签。我想,一旦用户点击“确定”后编辑,然后文本框应更改为标签。但不知何故,它不起作用。下面是JSFIDLE示例。请帮忙 http://jsfiddle.net/dilipkumar2k6/zEdY8/2/`“>JSFiddleLink我已经修改了您的,您必须将其更改为如下内容 <div ng-app="" ng-controller="controller" id="contentsDivID"> <div ng-

我使用的数据模型有“编辑”字段。根据“编辑”值,我使用文本框或标签。我想,一旦用户点击“确定”后编辑,然后文本框应更改为标签。但不知何故,它不起作用。下面是JSFIDLE示例。请帮忙

http://jsfiddle.net/dilipkumar2k6/zEdY8/2/`“>JSFiddleLink

我已经修改了您的,您必须将其更改为如下内容

<div ng-app="" ng-controller="controller" id="contentsDivID">
<div ng-repeat="chapter in chapters">
<ng:switch on="chapter.edit">
            <div ng:switch-when="true">
                <input type="text" ng-model="chapter.title" ng-model="chapter.title" />                
                <a ng-click="addChapter($index);"><i class="icon-ok"></i></a>
            </div>          
            <div ng:switch-when="undefined">
                    <label>{{chapter.title}}</label>
            </div>
            </ng:switch>        
    </div>       
</div>

您可能想签出-它应该会突出显示angular tracks如何更改模型。

我尝试了很多,但无法正确编辑JSFIDLE URL。我将尝试了解有关编辑器的更多信息。不过,您可以复制JSFIDLE URL以供参考。
function controller($scope)
{
    $scope.chapters=[
            {
                "_id": "567456746",
                "title": "Growth and Development",
                "type": "section",
                "edit":true
            },
            {
                "_id": "34563465345",
                "title": "Links between Areas of Development",
                "type": "section"
            },
            {
                "_id": "8776545645",
                "title": "Characteristics of Development",
                "thumbnail": "/xopus/images/templates/media-1-top-right.png",
                "type": "section"
            }
        ];

    $scope.addChapter = function(index) {
        $scope.chapters[index].edit = undefined;
    }
}