angular is a single-page application framework developed by Google, and is one of the more mainstream single-page application frameworks. There are many powerful areas, such as bidirectional data binding, the application of the backend MVC mode to the front end, custom instructions, etc.
Since it is a single page application, it must be inseparable from page switching. Let’s first talk about angular routing.
Angular uses route when implementing page switching.
<script src="js/plugins/angular/"></script> <script src="js/plugins/ui-router/"></script>
To load before. Then we need to register in the app.
(function () { ('demo', [ '', ]) })();
After registering, you need to configure route
function config($stateProvider, $urlRouterProvider,$httpProvider) { $("/home/get"); $stateProvider .state('login', { url: "/login", templateUrl: "../views/", }) .state('home', { abstract: true, url: "/home", templateUrl: "views/common/", }) .state('', { url: "/get", templateUrl: "views/", data: { pageTitle: 'Example view' } }) .state('', { url: "/post", templateUrl: "views/", data: { pageTitle: 'Example view' } }); } app = ('demo'); (config);
The configuration is completed at this point. Each state in the configuration has a view, which represents a page. The page jumps to the state, and the corresponding html file is in the corresponding file of templateUrl.
The above is the relevant knowledge about the usage and configuration of routes in AngularJs that the editor has shared with you. I hope it will be helpful to you.