2
|
I want to develop html5 SPA application for a thin client. There is no way to launch any web server on it. And I can't to make routing works without web server.
My index.html
|
Index id="link" href="/login">Go to login
- ng-repeat="number in numbers" >
{{number}}
angular.module('app', []).
config(function($routeProvider) {
$routeProvider.
when('/', {controller: HomeCtrl, templateUrl: 'index.html'}).
when('/login', {controller: LoginCtrl, templateUrl: 'login.html', resolve: function() {}}).
otherwise({redirectTo:'/'});
});
function HomeCtrl($scope) {
$scope.numbers = [1,2,3,4,5];
}
function LoginCtrl($scope) {
}
2
|
After a while, I made it works.
At first, I moved this piece into separate file
|
index.html
I've added this div
ng-view>
index.html
is used as "master page" or "layout" if you are familiar with asp.net. When you clicking at the link, content of the templateUrl file is inserting into placeholder div.
|
this is standard angular approach. Go through tutorial on docs site – charlietfl Mar 29 '13 at 11:20
| ||
Yeah, thanks. I got it now. – Dantix Mar 29 '13 at 11:30
| |||
This didn't work out for me. Out of the above modifications you mentioned in your answer, what prevented the request to the server? For me the app didn't work without a web server. – Andy Dufresne Jan 8 at 9:23
|
2
|
Angular is a client-side JS framework, so it doesn't need a web-server. Beside adding the ng-view (as you already figured out), you links need to have a hashbang in front (
#/login ), unless you're using html5mode.
So, having a hashbang in URLs is not a drawback, it's an option.
| ||
add comment |
0
|
Here some code from http://docs.angularjs.org/api/ng.$route
I think that same will work for you.
| ||||
|