0
簡単な質問ですが、答えを見つけるのに苦労します。角で文字列を連結
HTML
<div class="col-sm-5">
<input type="text" class="form-control" placeholder="key"
ng-model="main.key" ng-change="updateJson()">
</div>
<div class="col-sm-7">
<input type="text" class="form-control" placeholder="value"
ng-model="main.value" >
JS
$scope.updateJson=function(){
this.jsonObject +=this.key+":"+this.value;
};
私は、テキストボックスに入力すると、それはこれを出力し、UpdateJsonにバインドされているテキストフィールドを持っています。
undefinedundefined:undefinedundefined:undefinedundefined:undefined
タイプを正しく認識する方法で文字列を連結するにはどうすればよいですか? $log
を想定し
正確に何を出力していますか、見たいものは何ですか? – IonicBurger
this.jsonObjectのコンテキストまたは定義が表示されません。あなたが画面上で見ているものを詳しく教えてください。最高のplunkrを提供しています。 – MoMo
テンプレートのng-model = "main.key"のため、keyの値は$ scope.main.keyになります。しかし、基本的に未定義の出力が可能なさまざまな理由がありますが、@Dalorzoは言ったように、通常は「this」を使用しません。 – IonicBurger