javascript
Angular JS (2)
通過Angular JS的官方教學(xué)文檔,了解 routeProvider 的用法, angular.module('aaa').config(['$locationProvider','$routeProvider', funtion config($locationProvider, $routeProvider){
app.config.js ----
angular.
? module('phonecatApp').
? config(['$locationProvider' ,'$routeProvider',
??? function config($locationProvider, $routeProvider) {
????? $locationProvider.hashPrefix('!');
????? $routeProvider.
??????? when('/phones', {
????????? template: '<phone-list></phone-list>'
??????? }).
??????? when('/phones/:phoneId', {
????????? template: '<phone-detail></phone-detail>'
??????? }).
??????? otherwise('/phones');
??? }
? ]);
?
index.html ---
?<div ng-view></div>
phone-details.components.js
angular.
? module('phoneDetail').
? component('phoneDetail', {
??? template: 'TBD: Detail view for <span>{{$ctrl.phoneId}}</span>',
??? controller: ['$routeParams',??????????
????? function PhoneDetailController($routeParams) {
??????? this.phoneId = $routeParams.phoneId;??//取得變量
????? }
??? ]
? });
目前能刊出 module能嵌套,然后有component, config.
?
轉(zhuǎn)載于:https://www.cnblogs.com/hellocz/p/6094299.html
創(chuàng)作挑戰(zhàn)賽新人創(chuàng)作獎(jiǎng)勵(lì)來咯,堅(jiān)持創(chuàng)作打卡瓜分現(xiàn)金大獎(jiǎng)總結(jié)
以上是生活随笔為你收集整理的Angular JS (2)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国分布式光纤传感(DFOS)行业竞争现
- 下一篇: 一种在JS代码中实现模板变量替换的方法