AngularJS选择-自动选择选项
总之,我有一个选择框,我在Angular中创建了它,它包含一个图标而不是文本。您可以在这里看到,我必须使用ng bind html来显示unicode值,但现在不起作用的是,当选择框打开时,它不再“自动选择”当前值 选择框AngularJS选择-自动选择选项,angularjs,drop-down-menu,font-awesome,Angularjs,Drop Down Menu,Font Awesome,总之,我有一个选择框,我在Angular中创建了它,它包含一个图标而不是文本。您可以在这里看到,我必须使用ng bind html来显示unicode值,但现在不起作用的是,当选择框打开时,它不再“自动选择”当前值 选择框 <select ng-model="item.IconCssClass" class="fontawesomeselect"> <option ng-repeat="i in Icons" value="{{i.icon}}" ng-bind-htm
<select ng-model="item.IconCssClass" class="fontawesomeselect">
<option ng-repeat="i in Icons" value="{{i.icon}}" ng-bind-html="i.unicode|html"> </option>
</select>
在指令中(或多或少):
“选择”选项根本不是自动选择的,如果我做错了什么,您有什么想法吗?您将希望在选择正确图标的情况下使用来加载
<option ng-selected="i.icon === item.IconCssClass" ng-repeat="i in Icons" value="{{i.icon}}" ng-bind-html="i.unicode|html"></option>
您的范围中似乎不存在fa lock
图标。尝试将其添加到那里,或将所选图标更改为fa phone
或fa gbp
。好的,我的错,我选择了错误的演示项目,将立即更改。项目肯定在那里。我知道它会很简单!当我到家时,欢呼声会响起:)
scope.Icons = [
{ icon: 'fa-phone', unicode: '' },
{ icon: 'fa-gbp', unicode: '' }];
scope.item = { "IconCssClass": "fa-phone" };
<option ng-selected="i.icon === item.IconCssClass" ng-repeat="i in Icons" value="{{i.icon}}" ng-bind-html="i.unicode|html"></option>