Javascript 取消角度视图中的注释并更改视图
当我点击编辑按钮时,如果点击取消按钮返回,视图将被ng更改Javascript 取消角度视图中的注释并更改视图,javascript,angularjs,model-view-controller,Javascript,Angularjs,Model View Controller,当我点击编辑按钮时,如果点击取消按钮返回,视图将被ng更改 <div class="timeline-body"> <div marked="cmnt.content" class="markdown" ng-if = "editPostComment != $index " ></div> <!--Edit comment--> <
<div class="timeline-body">
<div marked="cmnt.content" class="markdown" ng-if = "editPostComment != $index " ></div>
<!--Edit comment-->
<div class="commentBox" ng-if = "editPostComment == $index " >
<textarea
rows="10" > {{cmnt.content}}</textarea>
<div class="hints">
<span class="boldtext">**Bold**</span>
<span class="italictext">_itlaics_</span>
<span class="striktext">~~strike~~</span>
<span class="codetext">'code'</span>
<span class="codetext">'''preformatted'''</span>
<span class="quotetext">>quote</span>
</div>
<div id="comment-btns">
<button class="btn btn-primary pull-left" ng-class="{'loading': commentig}" ng-disabled="commentig" ng-click="cancel()">Submit</button>
<button class="btn btn-primary pull-left cancel-edit" ng-class="{'loading': commentig}" ng-disabled="commentig" ng-click = "cancelEdit()">Cancel</button>
</div>
</div>
</div>
{{cmnt.content}
**大胆的**
_意大利语_
罢工~~
“代码”
“预格式化”
>引述
提交
取消
如果您的路线在单击“编辑注释”时发生了更改,您可以像在javascript中一样进行更改。试试这个
$scope.cancel = function(){
$window.history.back();
}
但如果它仅取决于nf if条件,则可以将editPostComment的值设置为不同于$index,如下所示
$scope.cancel = function(editPostComment){
editPostComment = null;
}
然后将“取消”按钮更改为
<button class="btn btn-primary pull-left" ng-class="{'loading': commentig}" ng-disabled="commentig" ng-click="cancel(editPostComment)">Submit</button>
提交
不,我不更改路线,当用户单击“取消”按钮时,我需要创建视图。当ng if=“editposcomment!=$index”时,会发生更改,但这不会发生,我只想在视图之间进行更改