Last active
October 20, 2015 19:15
-
-
Save jonahbron/7a1f0c5bff949e3765b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<md-input-container> | |
<label>Select Menu</label> | |
<md-select aria-label="Select menu" ng-model="vm.model"> | |
<md-option ng-value="item" ng-repeat="item in vm.options track by item.id" ng-bind="item.name" select-track-by="id" select-model="vm.model"></md-option> | |
</md-select> | |
</md-input-container> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
(function () { | |
angular | |
.module('myApp') | |
.directive('selectTrackBy', SelectTrackByDirective); | |
function SelectTrackByDirective() { | |
return { | |
restrict: 'A', | |
scope: { | |
selectModel: '=', | |
ngValue: '=', | |
selectTrackBy: '@' | |
}, | |
link: function (scope) { | |
if (scope.selectModel && scope.ngValue[scope.selectTrackBy] === scope.selectModel[scope.selectTrackBy]) { | |
scope.selectModel = scope.ngValue; | |
} | |
} | |
}; | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment