标签:子页面 angularjs config pre ati func http alice rip
<button id="button1">Load Html1</button> <button id="button2">Load Html2</button> <div></div> <script type="text/javascript"> $("#button1").click(function () { $("div").load("content1.jsp"); }); $("#button2").click(function () { $("div").load("content2.jsp"); }); </script>
第二种方法(建议第二种方法):
使用angularjs的路由机制,配合ng-view标签使用,具体查看下方链接。
var app = angular.module(‘ngRouteExample‘, [‘ngRoute‘]) .controller(‘MainController‘, function($scope) { }) .config(function($routeProvider, $locationProvider) { $routeProvider .when(‘/users‘, { templateUrl: ‘user-list.html‘, controller: ‘UserListCtrl‘ }) .when(‘/users/:username‘, { templateUrl: ‘user.html‘, controller: ‘UserCtrl‘ }); // configure html5 $locationProvider.html5Mode(true); });
<div ng-controller="MainController">
Choose:
<a href="users">user list</a> |
<a href="users/alice">user: alice</a>
<div ng-view></div>
</div>
则div会展示子页面。
http://harttle.com/2015/06/10/angular-route.html
或者看这个:http://blog.gejiawen.com/2015/12/15/routes-solution-on-angular-ng-route/
标签:子页面 angularjs config pre ati func http alice rip
原文地址:http://www.cnblogs.com/zipon/p/7201765.html