无法打开引导模式窗口作为路由 [英] Unable to open bootstrap modal window as a route

查看:96
本文介绍了无法打开引导模式窗口作为路由的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用引导到显示模式,并希望它成为一个锚标记为路由的点击中。
但我发现了一个模块错误和放大器;似乎无法弄清楚如何解决它。

I'm using bootstrap to display a modal and want it to be shown on click of a anchor tag as a route. But i'm getting a module error & can't seem to figure out how to resolve it.

HTML

<div ng-view>
    <div ng-controller="DetailPageCtrl">
      <a href="#/profile">Click here to open modal!</a>
    </div>
    <script type="text/ng-template" id="modalContainer">
        <div ng-controller="ProfileModalCtrl"></div>
    </script>
</div>

JS

var app = angular.module('plunker', ['ui.bootstrap']);
app.config(function($routeProvider) {
   $routeProvider
      .when('/profile', {
          templateUrl : 'modalContainer',
          controller : 'ProfileModalCtrl'
      });
})
app.controller('DetailPageCtrl', function($scope) {
   console.log("detail page");
});
app.controller('ProfileModalCtrl', function($scope, $modal) {
    $modal.open({templateUrl : 'modal.html'});
});

code在plnkr:
http://plnkr.co/edit/VbvuWzLqkICFzBYI9sL5?p=$p$pview

推荐答案

示范存在诸多问题。您还没有包括角route.js。使用您没有提供缺省路径,否则,你放在 NG-视图中的HTML

Demo is plagued with problems. You haven't included angular-route.js. You didn't provide a default path using otherwise and you placed html within ng-view

/* include script tag with `angular-route.js , then inject as dependency*/
var app = angular.module('plunker', ['ui.bootstrap', 'ngRoute']);
app.config(function($routeProvider) {
  $routeProvider.when('/', {
    templateUrl: 'default'
  })
    .when('/profile', {
      templateUrl: 'modalContainer',
      controller: 'ProfileModalCtrl'
    }).otherwise({
      redirectTo: '/'
    })
});

<div ng-view><!-- leave empty --></div>

<大骨节病> 演示

您也将遇到同样的声明 NG-控制器标记中在航线配置...选择一个或另一个

You will also run into problems declaring same ng-controller in markup as in route config...pick one or the other

这篇关于无法打开引导模式窗口作为路由的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆