简体   繁体   English

Bootstrap标签输入与角度ng-model问题

[英]Bootstrap tagsinput with angular ng-model issue

I have an angular form that is creating an object with tags: 我有一个用标签创建对象的角形:

<form class="form-horizontal">
 <div class="form-group">
  <label>Tags</label>
  <input type="text" id="tags-input" class="form-control" ng-model="beaconData.tag_list" name="beacon[tag_list]" placeholder="project, client 72, yellow, design"/>
 </div>

The id "#tags-input" is calling the tagsinput function as seen here: id“#tags-input”正在调用tagsinput函数,如下所示:

$('#tags-input').tagsinput('items');

With the id calling this function the ng-model="beaconData.tag_list" returns undefined. 使用调用此函数的id,ng-model =“ beaconData.tag_list”返回未定义。 If the tagsinput function is not called the ng-model returns the data with no problem. 如果未调用tagsinput函数,则ng-model会毫无问题地返回数据。

Does anyone might have an answer as to why this is happening? 有人可能会回答为什么发生这种情况吗?

The better question might be what does the tagsinput function do to the input values and why does it not return back to ng-model? 更好的问题可能是tagsinput函数对输入值做了什么,为什么它不返回ng-model?

在同事的帮助下,我能够捕获标签输入吐出的跨度值,并将其插入到我的对象中以进行保存。

    var tags = angular.element('.form-group div').children('span').map(function (i, s) { return angular.element(s).text(); });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM