我遇到的问题是模板的加载早于控制器中的参数,因此用户看到空块。
控制器:
app.controller('mainDashboardApi', ['$scope', '$http',
function($scope, $http) {
$http.get('api/dashboard/main').success(function(data) {
$scope.dashboard = data;
});
}
]);
Run Code Online (Sandbox Code Playgroud)
路由器:
$stateProvider
.state('dashboard', {
url: "/dashboard",
templateUrl: "dashboard",
controller: 'mainDashboardApi'
})
Run Code Online (Sandbox Code Playgroud)
参数加载完成后如何加载模板?