I have a directive where the model is not updating like I think it is supposed to. Here is my html:
<div class="text-area-container">
<textarea ng-model="chatText" ng-keyup="updateCount(chatText)"></textarea>
</div>
<input ng-disabled="disableCommentButton()" value="Comment" ng-click="addMessage(chatText)"/>
As you can see I have a ng-model attached to the <textarea>. I don't know if this affects anything, but I also have a ng-keyup attached to the element, that takes the model and looks at how many characters are in it. The last piece is I have a ng-disable on an input that is evaluated by a function. Here is my the link function of my directive:
link: function(scope) {
scope.chatText = '';
scope.countRemaining = 500;
scope.updateCount = function(chatText) {
scope.chatText = chatText;
scope.countRemaining = scope.maxChatCount - chatText.length;
};
scope.disableCommentButton = function() {
return _.isUndefined(scope.encounter) || _.isEmpty(scope.chatText);
};
}
The problem is that my scope.chatText is always undefined in the disableCommentButton method. I thought that by attaching a model to an element in the html, the I would have access to it on the scope. What am I missing here?