I'm trying to build an angularJs app, i'm also using requireJs with angularAMD package.
My project structure
|root
|-> bower_components
|-> html
|--> index.html
|--> tmpl
|---> test.html
|-> js
|--> app.js
|--> main.js
|--> controllers
|---> account.js
My app.js file:
define(['angularAMD', 'angular-route'], function (angularAMD) {
var app = angular.module("elara", ['ngRoute']);
app.config(function ($routeProvider) {
$routeProvider.when("/", angularAMD.route({
templateUrl: '/html/tmpl/test.html', controller: 'registerController',
controllerUrl: '/js/controllers/account.js'
})).otherwise({redirectTo: "/"});
});
return angularAMD.bootstrap(app);
});
my main.js file
require.config({
paths: {
'angular': '/bower_components/angular/angular.min',
'angular-route': '/bower_components/angular-route/angular-route.min',
'angularAMD': '/bower_components/angularAMD/angularAMD.min'
},
shim: { 'angularAMD': ['angular'], 'angular-route': ['angular'] },
deps: ['/js/app.js']
});
my index.html
<!DOCTYPE html>
<html>
<head>
<script data-main="/js/main.js" src="/bower_components/requirejs/require.js"></script>
</head>
<body>
<div ng-view></div>
</body>
</html>
my test html
<h1>test</h1>
So, i'm navigating to url /
, on the network tab i can see that my controller and template is loaded, but content of the template is not rendered into ng-view
element.