Angularjs Html with CSS with in the TAG
Angularjs Html with CSS with in the TAG
我试图在控制器中使用ng-bind-html属性和$sce依赖项在模板中插入HTML。但由于某些原因,它没有像预期的那样工作,它不能显示国家国旗。我能够检查和看到的标志代码值即将到来,但旗帜不能在下拉菜单中显示,当我在我的项目实施提前感谢。我的代码:
在HTML<ui-select ng-model="payment.baseCurrency" name="baseCurrency" class="currency" required data-ng-change="determinePaymentMethods()" theme="select2" >
<ui-select-match placeholder="{{'Select' | translate}}"><flag country="{{$select.selected.flagCode}}" size="16"></flag> {{$select.selected.code}} {{$select.selected.name}}
</ui-select-match>
<ui-select-choices repeat="baseCurrency in baseCurrencies track by baseCurrency.flagCode | searchFilter:{name:$select.search}" >
<flag country="baseCurrency.flagCode" size="16" ng-bind-html=" toTrusted($index) +' '+ baseCurrency.code +' '+ baseCurrency.name |highlight: $select.search"></flag>
</ui-select-choices>
</ui-select>
在控制器$scope.toTrusted = function(length) {
var country = $scope.baseCurrencies[length].flagCode;
return $sce.trustAsHtml('<span class="flag '+country+'"></span>');
};
在您的ui-select-choices
行中,您需要使用ng-repeat
而不仅仅是repeat
。
<ui-select-choices ng-repeat="baseCurrency in baseCurrencies track by baseCurrency.flagCode | searchFilter:{name:$select.search}" >
相关文章:
- Fighting with FRP
- issue with FB.Event.subscribe
- geolocation-marker.js conflict with markerclusterer.js
- Angular 2.0 with JavaScript or TypeScript?
- 为什么不推荐使用“with”?是否有更好或其他方法可以“下降”到对象的命名空间
- Intercept the cellSubmit jqGrid
- WebComponentsJS with IE10
- 指令的模板必须只有一个根元素:With restrict E&替换true
- CSS中的游标属性似乎不适用于USB On The Go
- timeago.js with datatable and PHP
- Ajax and Json with Rails
- errors with Javascript try catch
- how to split a string with ','
- How efficient is the "with" statement?
- Save in MYSQL the value of a div with HTML5 Drag &Drop
- jQuery select box with respect to the change event
- Using JSONP with the flickr api
- PHP with Javascript - What is the scope of PHP variables ins
- Angularjs Html with CSS with in the TAG
- The JSON structure with Javascript