【发布时间】:2020-09-24 18:37:45
【问题描述】:
我正在尝试在我自己的网站中创建一个用于创建“推文”的组件,并且当我尝试将某些内容写入 textarea 时(无法写入任何内容)
我有这张显示错误的图片:
这是我在“editorTweets.component.js”中的代码:
class EditorTweetsComponentCtrl {
constructor($scope, $state, User, Tweets){
"ngInject";
this._Tweets = Tweets;
this._$state = $state;
this._$scope = $scope;
this.currentUser = User.current;
console.log(this.currentUser);
this.tweet = {
body: ''
}
}
submit() {
console.log(this.tweet.body);
}
}
let EditorTweets = {
bindings: {
tweet: '='
},
controller: EditorTweetsComponentCtrl,
templateUrl: 'components/tweets-helpers/editorTweets.html'
};
export default EditorTweets;
和 .html 视图:
<div class="container-editor-tweets">
<div class="left-editor-tweets">
<img ng-src="{{$ctrl.currentUser.image}}" alt="Img-User"/>
</div>
<div class="right-editor-tweets">
<div class="editor-tweet-body">
<textarea name="tweet_msg" id="tweet_msg" placeholder="Whats going on?..." ng-model="$ctrl.tweet.body"></textarea>
</div>
<div class="editor-tweet-options">
<button class="btn-submit-tweet" type="button" ng-click="$ctrl.submit()">Tweet</button>
</div>
</div>
</div>
【问题讨论】:
-
您是否尝试过将推文附加到范围而不是像
scope: { 'tweet': '='}这样的绑定
标签: javascript node.js angularjs