我将我的角度应用程序设置为Symfony应用程序中的捆绑包。由于此限制,角度应用程序的目录结构是不同的。所有公共资源都符号链接到静态目录,包括部分。我得到了应用程序加载,控制器触发,但没有部分加载他们的特定控制器。我把它作为一个独立的应用程序(在Symfony之外)工作,所以我必须错过一些新的配置。
index.html.twig:
注意:javascript文件加载得很好 - 这是正确的资产路径
<body ng-controller="MainController">
<nav class="navbar navbar-default" role="navigation">
<div class="container">
<ul class="nav navbar-nav navbar-right">
<li class="active"><a href="#/">Home</a></li>
<li><a href="#/groups">Groups</a></li>
</ul>
</div>
</nav>
<div ng-view=""></div>
<div ng-view></div> <!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<script src="//cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.20/angular.min.js"></script>
<script src="bundles/translations/webadmin/app/js/ngroute.js"></script>
<script src="bundles/translations/webadmin/app/js/app.js"></script>
<script src="bundles/translations/webadmin/app/js/services.js"></script>
<script src="bundles/translations/webadmin/app/js/controllers.js"></script>
<script src="bundles/translations/webadmin/app/js/filters.js"></script>
<script src="bundles/translations/webadmin/app/js/directives.js"></script>
</body>
app.js:
注意:我尝试将templateUrl设为partials /以及
angular.module('myApp', [
'ngRoute',
'myApp.filters',
'myApp.services',
'myApp.directives',
'myApp.controllers'
]).config(['$routeProvider', function($routeProvider) {
$routeProvider.when('/groups', {templateUrl: 'bundles/translations/webadmin/app/partials/groups.html', controller: 'GroupsController'});
$routeProvider.when('/', {templateUrl: 'bundles/translations/webadmin/app/partials/home.html', controller: 'HomeController'});
$routeProvider.otherwise({redirectTo: '/'});
}]);
controllers.js
注意:警报启动很好,但部分内容不会加载......
angular.module('myApp.controllers', [])
.controller('MainController', ['$scope', function($scope) {
alert('here?');
}])
.controller('HomeController', ['$scope', function($scope) {
alert('here2');
}])
.controller('GroupsController', ['$scope', function($scope) {
// TODO see below
}]);
控制台输出:
Consider using 'dppx' units, as in CSS 'dpi' means dots-per-CSS-inch, not dots-per-physical-inch, so does not correspond to the actual 'dpi' of a screen. In media query expression: (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) translations:1
Blink is considering rejecting non spec-compliant cross-origin web font requests: https://d3nkxvtkt5c8vi.cloudfront.net/0.4.2/fonts/proxima_nova_light_0.woff. Please use Access-Control-Allow-Origin to make these requests spec-compliant.
知道我在这里缺少什么吗?任何帮助将不胜感激。
答案 0 :(得分:0)