问题
does anyone know how to get my code working. I'm trying to make a user creation dialog and want to send post data using ngResource, I've already configured my PHP backend and its working as expected. Now, my problem is appending errors on the dialog, I've tried adding dummy data but ngRepeat does not work for me. I've also tried different steps debugging the problem but nothing works for me. I've also researching about the issue but no luck. here is my code:
<div name="errors" id="errors" class="alert alert-error">
<li ng-repeat="error in dialog.errors">{{ error }}</li>
</div>
try to look at the link http://jsfiddle.net/QCQrF/
回答1:
@Ryan there were number of things going on in your jsFiddle but the most important problem was the way you were specifying dialog's template. A template can be either specify as string (using the template
property) or as a partial (templateUrl
).
If you move a template to a partial you can specify it like follows:
var dialogOpts = {
backdrop: true,
keyboard: true,
backdropFade: true,
backdropClick: true,
templateUrl: 'login-dialog.html',
controller: 'DialogCtrl',
resolve: { dialogScope : {
errors : ['error1', 'error2'],
title :'Add User',
btnTxt : 'Create User'
}}
};
Also, IMO it is easier to pass data to be exposed on the dialog's scope using the resolve
property instead of using dialog's instance.
I've converted your fiddle to a plunk to show this: http://plnkr.co/edit/iGIwPBj9zBPgX3IUwBNj?p=preview
You might find $dialog's service additional documentation helpful in further exploaration of this service: https://github.com/angular-ui/bootstrap/blob/master/src/dialog/README.md
As the last remark, I've noticed that you are were passing the $event
argument to event handlers (all calling preventDefault()
on them) while this is unnecessary.
来源:https://stackoverflow.com/questions/14539038/ngrepeat-does-not-work-inside-angularui-bootstrap-dialog