带angularjs的引导标记输入中的未定义方法
我正在尝试使用页面中描述的方法在我的angularjs应用程序中实现jquery插件带angularjs的引导标记输入中的未定义方法,angularjs,twitter-bootstrap,Angularjs,Twitter Bootstrap,我正在尝试使用页面中描述的方法在我的angularjs应用程序中实现jquery插件 <bootstrap-tagsinput ng-model="cities" typeahead-source="queryCities" tagclass="getTagClass" itemvalue="value" itemtext="text"> </bootstrap-tagsinput> <script> angu
<bootstrap-tagsinput
ng-model="cities"
typeahead-source="queryCities"
tagclass="getTagClass"
itemvalue="value"
itemtext="text">
</bootstrap-tagsinput>
<script>
angular.module('AngularExample', ['bootstrap-tagsinput'])
.controller('CityTagsInputController',
function CityTagsInputController($scope) {
// Init with some cities
$scope.cities = [
{ "value": 1, "text": "Amsterdam", "continent": "Europe" },
{ "value": 4, "text": "Washington", "continent": "America" },
{ "value": 7, "text": "Sydney", "continent": "Australia" },
{ "value": 10, "text": "Beijing", "continent": "Asia" },
{ "value": 13, "text": "Cairo", "continent": "Africa" }
];
$scope.queryCities = function (query) {
return $http.get('cities.json');
};
$scope.getTagClass = function (city) {
switch (city.continent) {
case 'Europe': return 'badge badge-info';
case 'America': return 'label label-important';
case 'Australia': return 'badge badge-success';
case 'Africa': return 'label label-inverse';
case 'Asia': return 'badge badge-warning';
}
};
}
);
</script>
我已包括两个文件:
<script type="text/javascript" src="/viktor/public/js/tagsinput.js"></script>
<script type="text/javascript" src="/viktor/public/js/ng-tagsinput.js"></script> // I have renamed those files.
最后添加了示例中定义的指令:
<input type="text" class="form-control" bootstrap-tagsinput>
有人遇到过同样的问题吗?页面上有一个代码如何使用它
<bootstrap-tagsinput
ng-model="cities"
typeahead-source="queryCities"
tagclass="getTagClass"
itemvalue="value"
itemtext="text">
</bootstrap-tagsinput>
<script>
angular.module('AngularExample', ['bootstrap-tagsinput'])
.controller('CityTagsInputController',
function CityTagsInputController($scope) {
// Init with some cities
$scope.cities = [
{ "value": 1, "text": "Amsterdam", "continent": "Europe" },
{ "value": 4, "text": "Washington", "continent": "America" },
{ "value": 7, "text": "Sydney", "continent": "Australia" },
{ "value": 10, "text": "Beijing", "continent": "Asia" },
{ "value": 13, "text": "Cairo", "continent": "Africa" }
];
$scope.queryCities = function (query) {
return $http.get('cities.json');
};
$scope.getTagClass = function (city) {
switch (city.continent) {
case 'Europe': return 'badge badge-info';
case 'America': return 'label label-important';
case 'Australia': return 'badge badge-success';
case 'Africa': return 'label label-inverse';
case 'Asia': return 'badge badge-warning';
}
};
}
);
</script>
angular.module('AngularExample',['bootstrap-tagsinput']))
.controller('CityTagsInputController',
功能CityTagsInputController($scope){
//与一些城市合作
$scope.cities=[
{“价值”:1,“文本”:“阿姆斯特丹”,“大陆”:“欧洲”},
{“价值”:4,“文本”:“华盛顿”,“大陆”:“美国”},
{“价值”:7,“文本”:“悉尼”,“大陆”:“澳大利亚”},
{“价值”:10,“文本”:“北京”,“大陆”:“亚洲”},
{“价值”:13,“文本”:“开罗”,“大陆”:“非洲”}
];
$scope.queryCities=函数(查询){
返回$http.get('cities.json');
};
$scope.getTagClass=函数(城市){
交换机(城市、大陆){
案例“欧洲”:返回“徽章信息”;
案例“美国”:返回“标签重要”;
案例“澳大利亚”:返回“徽章成功”;
案例“Africa”:返回“label-label-inverse”;
案例“亚洲”:返回“徽章警告”;
}
};
}
);
AngularJS Support下面的第4行您可能想看一看:@john-您能帮我了解一下它的工作原理吗?我也做了你提到的所有事情,但对我来说bootsrap tagInput HTL tag本身无法识别,UIS上也没有显示任何内容。我们如何在angularjs中跟踪onchange或onadded方法?你能帮忙吗?
<bootstrap-tagsinput
ng-model="cities"
typeahead-source="queryCities"
tagclass="getTagClass"
itemvalue="value"
itemtext="text">
</bootstrap-tagsinput>
<script>
angular.module('AngularExample', ['bootstrap-tagsinput'])
.controller('CityTagsInputController',
function CityTagsInputController($scope) {
// Init with some cities
$scope.cities = [
{ "value": 1, "text": "Amsterdam", "continent": "Europe" },
{ "value": 4, "text": "Washington", "continent": "America" },
{ "value": 7, "text": "Sydney", "continent": "Australia" },
{ "value": 10, "text": "Beijing", "continent": "Asia" },
{ "value": 13, "text": "Cairo", "continent": "Africa" }
];
$scope.queryCities = function (query) {
return $http.get('cities.json');
};
$scope.getTagClass = function (city) {
switch (city.continent) {
case 'Europe': return 'badge badge-info';
case 'America': return 'label label-important';
case 'Australia': return 'badge badge-success';
case 'Africa': return 'label label-inverse';
case 'Asia': return 'badge badge-warning';
}
};
}
);
</script>