简体   繁体   中英

Angularjs select in templateCache

well I get some data from php from a data base, and then have it in angularjs like that:

stuff= 
[
    {name:'stuff1', id:'1'},
    {name:'stuff2', id:'2'},
    {name:'stuff3', id:'3'},
    {name:'stuff4', id:'4'}
];

and i want to add this in a select that it is in a templateCache

-code-
.run(['$templateCache',function($templateCache,$scope){
$templateCache.put('/dialogs/editUser.html',
-code-
+'<select data-ng-options="s.name for s in stuff" data-ng-model="selected_s"> </select>'
-code-
}])

I'm using the angular-dialog-service code from me-conroy, and build a custom dialog.

It supposed to be a dialog that is showing up, if you want to edit something, then you should select from 'stuff', but i couldn't figure out how. Maybe someone could gave me a tip, or is that even possible?? The other Code is working, and i dont get an error, just an empty select

The problem is related to that you are using whole object as model and select in angular don't really work with it. Change your code to work with id instead.

<select data-ng-options="s.id as s.name for s in stuff" data-ng-model="selected_s"> </select>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM