First, the HTML code is this:
<label>name des leiters:</label>
<select name= "Leaderid" id= "Selectleaderid" > <option ng-repeat= "manager in managers" value= "leader_id={{ Manager.id}}&leader_name={{manager.name}}&leader_email={{manager.email}} "callback-on-end>{{ Manager.name}}</option></select>
Because only one ID is determined, you need to set the option's selected value, but not directly with Ng-model or $ (). Val () to set because value is a long string of things = = 0. 0 Why should I write such a code?
Therefore, you can only complete the setup by calling the callback function after the ng-repeat loading is complete.
The code is as follows:
App.directive ("Callbackonend", function ($timeout) { return { restrict: "A", link:function (scope, Element, Attrs) { if (scope. $last) { $timeout (function () { var select = document.getElementById (" Selectleaderid "); for (var i = 0;i < select.options.length;i++) { var parts = []; Parts = Select.options[i].value.split (' & '); if (parts[0].substr) = = Scope.selectleaderid) { select.options[i].selected = true;} } ); } } }; });
Add a directive, and note that you will need to use $timeout to load the option each time, instead of the last load.
Finally, I wish you kids a good study, day up, haha haha next week Easter holiday can come to a Spanish Portugal tour!
Angularjs's Ng-repeat callback