首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何使用引导程序在AngularJS应用程序中显示弹出

如何使用引导程序在AngularJS应用程序中显示弹出
EN

Stack Overflow用户
提问于 2014-11-17 19:11:55
回答 3查看 2K关注 0票数 0

我需要在视野中显示4-5弹出。到目前为止,我正在使用引导来显示弹出窗口。但我的问题是,我的html页面变得沉重,有页面自己的内容和5弹出的内容。我想在不同的html页面中移动每个弹出窗口的内容。请建议一下。

提前谢谢。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2014-11-17 20:08:31

我猜“弹出”你是指模态窗口。我同意上面的说法,使用角-ui模式服务非常好。但是,与使用ng-include的建议不同,我建议使用模式的内置"templateUrl“将标记保存在一个单独的文件中。我在我的项目中使用了这个,而且效果很好。

票数 1
EN

Stack Overflow用户

发布于 2014-11-17 19:29:31

您可以使用角度用户界面模式窗口。

http://angular-ui.github.io/bootstrap/

为了分离模板,可以在脚本中使用<div data-ng-include="'/templte/modal.html'"></div>

票数 0
EN

Stack Overflow用户

发布于 2014-11-18 09:00:45

ng-如果您使用一个带有多个页面或选项卡的对话框,则包含=“”是很好的。只更改html名称很好,并使其变得简单。例如:

代码语言:javascript
复制
<div ng-include="getCurrentPage()"></div>

控制器

代码语言:javascript
复制
scope.getCurrentPage = function(){
    return "path/to/html" + scope.pageId + ".html";
};

但是,对于您目前的情况,我推荐Barnabas Kendall的方式。我可以分享我用过的东西。我为一组调制解调器创建了一个单一的服务。

角模

代码语言:javascript
复制
var app = angular.module('app', ['ui.bootstrap']);

服务(用于modals组)

代码语言:javascript
复制
app.service('ModalDialogs', function ($modal) {
    return {
        modalDialog1: modalDialog1,
        modalDialog2: modalDialog2
    };

    var modalDialog1 = function (size, param1, param2) {
        var ControllerForDialog1 = function (scope, modalInstance, param1, param2) {
            scope.cancel = function () {
                modalInstance.dismiss('cancel');
            };

            // todo
        };

        return $modal.open({
            templateUrl: 'path/to/dialog1.html',
            size: size,
            resolve: {
                param1: function () {
                    return param1 + param2;
                },
                param2: function () {
                    return "this can be any value";
                }
            },
            controller: ControllerForDialog1
        });
    };

    var modalDialog2 = function (size, param1) {
        var ControllerForDialog2 = function (scope, modalInstance, anotherParam) {
            scope.cancel = function () {
                modalInstance.dismiss('cancel');
            };

            // todo
        };

        return $modal.open({
            templateUrl: 'path/to/dialog2.html',
            size: size,
            resolve: {
                anotherParam: function () {
                    return "this can be any value" + param1;
                }
            },
            controller: ControllerForDialog2
        });
    };
});

用法

代码语言:javascript
复制
app.controller('MainController', function($scope, ModalDialogs){
    ModalDialogs.modalDialog2('lg', 'YourName');
});
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26980115

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档