【问题标题】:angularjs modal change template?angularjs模态更改模板?
【发布时间】:2014-10-19 22:14:35
【问题描述】:

我有一个列表页面,当单击一行时,会弹出一个模态视图页面以显示其内容,然后在其中单击编辑按钮,我希望弹出视图页面可以直接编辑页面,即从一个模态视图页面重定向到另一个模态编辑页面,我使用angularjs模态显示视图页面,那么如何将模态内容更改为编辑页面?

【问题讨论】:

    标签: angularjs modal-dialog


    【解决方案1】:

    您可以使用 $templateCache.get() 或发出 http 请求来获取您的模板。 然后使用 $compile(template) 编译它。模板编译后,您可以使用 jQuery/jqLit​​e 将模板放置在 DOM 中的任何位置 — 所有角度绑定都可以使用。

    【讨论】:

    • 谢谢,不过我是 angularjs 的初学者,$compile 和 templateCache 对我来说太高级了
    【解决方案2】:

    感谢 Girafa,我使用了一种简单的方法(尽管代码有些冗长)。我创建了两个控制器,当打开视图模式时,在选项中传递 $scope,然后单击编辑按钮时,首先调用取消当前模式,然后打开编辑视图。像这样:
    $modalInstance.close('取消'); $scope.openedit(id);

    【讨论】:

    • 'cancel' 参数是干什么用的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 1970-01-01
    • 2015-10-22
    • 2019-01-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多