首页 > 解决方案 > 角度js,使用模型添加数据并返回视图

问题描述

我有一个问题:我有标签列表,我可以添加标签。用于添加标签使用模式

我会重复我的标签列表。但是当我添加标签时,我会在我的 console.log 上看到它,但他不会在我的 ng 重复上打印:

我的代码:

    $scope.createTag = function () {
    apiREST.execute('POST', "ctrl", "tag",{datas: $scope.tag}, function (error) {
        if(error == true){
            Growl.error({title: 'ERROR', text: 'Need name value'});
        }else{
            Growl.success({title: "Success !", text: "Tag successfuly created !"});
        }
        $scope.getTags();
    }, );

};

$scope.getTags = function() {
    apiREST.execute("GET","ctrl","tag",{},
            function (data) {
                $scope.tags = data.TAGS;
                console.log($scope.tags); // i see my new tag
            },  
            function () {
                console.log("error");
            });
};

和我的看法

                    <div class="col-md-8 text-bold"> 
                    Tags
                    <br>
                <i class="text-danger"> click on tags for select </i>
                </div>
                <div class="col-md-2 text-bold">        
                   <button class="btn btn-info"  id="" ng-click="openModalTagg();">
                    Add Tags
                  </button></div>
            </div>

            <br>
            <div class="tagCss">
            <span ng-repeat="ctc in tags" >
                <button class="btn btn-primary tag" style="margin-top: 20px; font-size: 12px;" id='{{ctc.id_tag}}' ng-click="selectTag()" >{{ctc.name_tag}}</button>
            </span>
             </div>

泰为你的帮助

标签: javascriptangularjsmodal-dialog

解决方案


推荐阅读