javascript - Angular JS 中的嵌套 View

标签 javascript ajax angularjs

我正在尝试更新另一个 View 中 View 的一部分。

但是链接不断覆盖外部 ng-view

如何在 ng-view 中更新 ng-view ?

最佳答案

这个库应该完全满足您的需求:

http://angular-route-segment.com

演示站点:http://angular-route-segment.com/src/example/

它比 ui-router 使用起来简单得多。示例路由配置如下所示:

$routeSegmentProvider.

when('/section1',          's1.home').
when('/section1/prefs',    's1.prefs').
when('/section1/:id',      's1.itemInfo.overview').
when('/section1/:id/edit', 's1.itemInfo.edit').
when('/section2',          's2').

segment('s1', {
    templateUrl: 'templates/section1.html',
    controller: MainCtrl}).

within().

    segment('home', {
        templateUrl: 'templates/section1/home.html'}).

    segment('itemInfo', {
        templateUrl: 'templates/section1/item.html',
        controller: Section1ItemCtrl,
        dependencies: ['id']}).

    within().

        segment('overview', {
            templateUrl: 'templates/section1/item/overview.html'}).

        segment('edit', {
             templateUrl: 'templates/section1/item/edit.html'}).

        up().

    segment('prefs', {
        templateUrl: 'templates/section1/prefs.html'}).

    up().

segment('s2', {
    templateUrl: 'templates/section2.html',
    controller: MainCtrl});

关于javascript - Angular JS 中的嵌套 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18389921/

相关文章:

javascript - 合并两个 html 表单中的数据元素无法正常工作

javascript - 如何防止 ember-data 向服务器发送请求?

javascript - jQuery - 使 DIV 既可拖动又可拖放

javascript - 如何使用async :false in angular js 1. 6,让java脚本下一行执行get block until $http completed

javascript - Angular 和 SEO - 创建静态 HTML 版本

Javascript:如何在屏幕上移动 div 或 span 而不更改正在移动的元素的样式属性?

javascript - 使用 AJAX 调用 PHP 文件时出现 EOF/无法加载错误

javascript - 将 JavaScript 选择变量传递给 Rails Controller

javascript - 如何制作jquery多图预览

javascript - AngularJS 指令绑定(bind)链接 : has no access to scope variables