我想在点击特定网址时加载文件,但我还没有取得任何成功:
这就是我的代码的样子:
.state('admin.resources', {
url: '/resources',
templateUrl: 'views/admin/resources.html',
controller: 'ResourceController as res',
resolve: {
loadMyFiles: function ($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'venture',
files: [
'bower_components/angular-ui-tinymce/src/tinymce.js'
]
})
}
}
})
如果我将它包含在index.html中,它可以正常工作:
<script type="text/javascript" src="bower_components/angular-ui-tinymce/src/tinymce.js"></script>
我不想从index.html加载id,因为我不想在加载网站后加载该页面。我需要在单独的页面上使用该脚本。
有什么建议吗?
答案 0 :(得分:0)
要使用oclazyload,您需要将其放在$stateProvider.state('index', {
url: "/", // root route
views: {
"lazyLoadView": {
controller: 'AppCtrl', // This view will use AppCtrl loaded below in the resolve
templateUrl: 'partials/main.html'
}
},
resolve: { // Any property in resolve should return a promise and is executed before the view is loaded
loadMyCtrl: ['$ocLazyLoad', function($ocLazyLoad) {
// you can lazy load files for an existing module
return $ocLazyLoad.load('js/AppCtrl.js');
}]
}
});
属性中:
$(function(){
$("#my-button").click(function(){
$("#dialog")
.dialog({ "title" : "My Dialog" })
.dialogExtend({
"maximizable" : true,
"dblclick" : "maximize",
"icons" : { "maximize" : "ui-icon-arrow-4-diag" }
});
});
所有内容都在 With your router 中进行了解释和详细记录。