第一句子网 - 唯美句子、句子迷、好句子大全
第一句子网 > angularjs 让当前路由重新加载_关于angularjs 使用路由动态加载页面并加载JS的问题...

angularjs 让当前路由重新加载_关于angularjs 使用路由动态加载页面并加载JS的问题...

时间:2020-05-10 16:31:00

相关推荐

angularjs 让当前路由重新加载_关于angularjs 使用路由动态加载页面并加载JS的问题...

使用angularJs 的 ngRoute 构建单页面应用时因为页面应用比较多想实现动态加载的功能,根据事件尽心路由配置

如果直接使用 绑定模块的配置方法可以获取对应页面数据,

// create the module and name it scotchApp

var scotchApp = angular.module('scotchApp', ['ngRoute']);

// configure our routes

scotchApp.config(function($routeProvider) {

$routeProvider.when('/', {

controller : 'myCtrl',

templateUrl : getUrl("wxappList"),

});

});

scotchApp.controller('mainController', function($scope) {

});

如果在控制器中声名方法就不会执行

var scotchApp = angular.module('scotchApp', ['ngRoute']);

// configure our routes

scotchApp.controller('mainController', function($scope) {

$scope.run = function(){

scotchApp.config(function($routeProvider) {

$routeProvider.when('/', {

controller : 'myCtrl',

templateUrl : getUrl("wxappList"),

});

});

}

$scope.run();

});

因为加载的页面会越来越多所以想实现动态加载的功能,同时加载对应的JS文件。。。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。