1
我刚开始使用ngTagsInput角度库,我在更新模型时遇到问题。我在ionicPopup中显示标签输入,并且有趣的是标签添加的事件触发,它显示$ scope.sites []被填充。ngTagsInput没有绑定到模型
当我调用$ scope.test()时,该数组是空的。唯一能够保持价值的上下文是与添加在标签上的事件关联的方法。
这里是一个简化的控制器,例如:
$scope.sites = [];
$scope.addSites = function() {
// this works
console.log("In addSites");
console.dir($scope.sites);
}
$scope.test = function() {
// in any other method $scope.sites is empty
console.dir($scope.sites);
}
在我看来,我有标签元素定义为:
<tags-input ng-model="sites" add-on-space="true" placeholder="Add Site Numbers" on-tag-added="addSites($tag)"></tags-input>
我觉得它非常奇怪的是,一个$ scope变量可以包含的值我期望在图书馆事件的背景下,但不在此之外。
有没有什么特别的事情需要在绑定方面完成?据文件去,我没有看到我失踪。任何建议将不胜感激。