ngRepeat does not work inside AngularUI bootstrap dialog

旧巷老猫 提交于 2019-12-24 11:36:54

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!