从Yeoman角式脚手架上进行基本安装,并且在整个使用期内,我无法让路由器加载基本模板。这是我的设置
// index.html
<body ng-app="mvmdApp">
<div class="container" ng-view=""></div>// not sure how ng-view plays into this
// app.coffee
myAppModule = angular.module("mvmdApp", [])
.config( ($routeProvider, $locationProvider) ->
$locationProvider.html5Mode true
$routeProvider
.when("/",
templateUrl: "views/main.html"
controller: "MainCtrl"
)
.when("/youtube",
templateUrl: "views/youtube.html"
controller: "YoutubeCtrl"
)
)
// main.js
angular.module('mvmdApp')
.controller 'MainCtrl', ($scope) ->
$scope.awesomeThingss = [
'HTML5 Boilerplate'
'AngularJS'
'Karma'
]
$scope.youtube = ( $scope ) ->
alert 'hi'
.controller "YoutubeCtrl", ( $scope ) ->
alert 'Work!'
// views/youtube.html
<div class="youtube-unit">
<div class="outer-frame">
<div class="inner-frame">
<iframe width="560" height="315" src="//www.youtube.com/embed/2FNEiTjcMM0" frameborder="0" allowfullscreen="allowfullscreen"></iframe>
</div>
</div>
</div>
主控制器加载正常,我尝试了尽可能多的复制它
转到localhost:9000 / youtube给我一条Cannot GET /youtube
消息。我觉得我已经尝试了所有组合。
Html5模式不仅涉及Javascript,还需要服务器来支持它。
尝试/ youtube时,它首先进入服务器,如果服务器无法管理它,则应渲染有角度的应用程序,以便路由器可以捕获路由并显示所需的内容。
我不确定Yeoman是否支持html5模式。
您可以尝试类似于Yeoman的linemanjs,它支持html5模式。
如果您想使用Yeoman,则将google用于yeoman的html5模式或使用hashbang :)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句