Vote count:
0
I have a problem with a nested controller. View and controller are here:
<div ng-repeat="comment in comments | reverse" ng-attribute-id="{{ 'commentContainer_' + comment.comment_id }}" class="commentContainer" ng-controller="singleCommentCtrl as comCtrl">
<div class="mComment" ng-class="{mCommentRight: comment.user == currentUser.nicename}">
....
<span class="time">
<span ng-if="comment.user != currentUser.nicename" ng-click="comCtrl.currentComment = comment" ng-hide="comCtrl.currentComment == comment">Reply</span>
</span>
</div>
<form class="replyBox" style="display: inline;" ng-show="comCtrl.currentComment">
<h>{{ comCtrl.currentComment }}</h>
<h>{{comCtrl.myReply.txt }}</h>
<input id="mTextBox" type="text" class="sharedTextArea" ng-model="comCtrl.myReply.txt"></input>
</form>
</div>
function singleCommentCtrl($scope) {
$scope.currentComment = "";
$scope.myReply = {
"txt": "@"
}
}
Then both the with comCtrl.myReply.txt are empty whereas the one with comCtrl.currentComment is correct.<h> and <input>
P.S. This is my first post and almost crying trying to format the codeblocks.
asked 59 secs ago
Angularjs scope variable not showing
Aucun commentaire:
Enregistrer un commentaire