【发布时间】:2015-06-02 10:13:12
【问题描述】:
我在获取 jQuery 时遇到了一些问题,我更熟悉使用 ajax 加载 html 然后将其添加到视图中。模板已经加载,然后我需要通过 ajax 从外部获取一些数据并将其放入元素中。但是 AngularJs 在这一切之前运行,我希望它等到所有数据都加载完毕。
编辑:澄清一下,这里是代码,我运行 custom.js。
$stateProvider
// Companyresults
.state('companyresults', {
url: "/companyresults.html",
templateUrl: "views/companyresults.html",
data: {pageTitle: 'Dashboard', pageSubTitle: 'statistics & reports'},
controller: "CompanyResultsController",
resolve: {
deps: ['$ocLazyLoad', function($ocLazyLoad) {
return $ocLazyLoad.load({
name: 'MetronicApp',
insertBefore: '#ng_load_plugins_before', // load the above css files before '#ng_load_plugins_before'
files: [
'../../../assets/admin/layout3/scripts/custom.js',
'js/controllers/CompanyResultsController.js'
]
});
}]
}
});
还有..
'use strict';
MetronicApp.controller('CompanyResultsController', function($rootScope, $scope, $http, $timeout) {
$scope.$on('$viewContentLoaded', function() {
// initialize core components
Metronic.initAjax();
});
});
【问题讨论】:
-
我建议通过 Angular 的 $http 服务加载 AJAX 数据。
标签: jquery html ajax angularjs