The picture you want to achieve is as follows:
Now I have implemented the basic shape and function, but when I click on an icon and change the icon next to "Adapted Devices", this function does not produce the expected results.
Please tell me which part I wrote wrong?
1. Here are the icons that will be replaced by clicking the icons in different drop-down boxes next to "Adapted Devices".
(This is the function I want to achieve.)
<i
ng-class="{' ico-screen-pc':pc,
' ico-screen-projector':projector,
' ico-screen-tv':tv}">
</i>
2. This part is in the drop-down box. You can click on different icons
<ul ng-show="show_apparatus">
<li ng-click="displayModeData.choose_display('pc')">
<i title="PC显示屏" class="ico-screen-pc"></i>
</li>
<li ng-click="displayModeData.choose_display('projector')">
<i title="投影仪" class="ico-screen-projector"></i>
</li>
<li ng-click="displayModeData.choose_display('tv')">
<i title="TV显示屏" class="ico-screen-tv"></i>
</li>
</ul>
3. This part is the function code of js
$scope.pc = true;
$scope.displayModeData = {
pc: true,
choose_display : function( displayMode ){
$scope.pc = ( displayMode === 'pc' );
$scope.projector = ( displayMode === 'projector' );
$scope.tv = ( displayMode === 'tv' );
}
};
Please tell me which part of my writing is wrong?
PHPz2017-05-15 17:05:12
Come on, change it according to mine:
$scope.displayModeData = {
pc: true,
choose_display : function( displayMode ){
$scope.displayMode = displayMode;
}
};
<i
ng-class="{' ico-screen-pc':displayMode === 'pc',
' ico-screen-projector': displayMode === 'projector',
' ico-screen-tv': displayMode === 'tv'}">
</i>
某草草2017-05-15 17:05:12
<i class="{{selectedClass}}"> </i>
<ul ng-show="show_apparatus">
<li ng-click="$parent.selectedClass = icon.className" ng-repeat="icon in icons">
<i title="{{icon.title}}" class="{{icon.className}}"></i>asdadasd
</li>
</ul>
$scope.icons = [
{title: 'PC显示屏', className: 'ico-screen-pc'},
{title: '投影仪', className: 'ico-screen-projector'},
{title: 'TV显示屏', className: 'ico-screen-tv'}
];
$scope.selectedClass = $scope.icons[0].className;