我正在构建一个应用程序 authenticate with Moodle从 Moodle Web 服务获取 Json 数据,并使用 AngularJs 在应用程序中显示数据。 Moodle webservice有多种功能,所以我需要multiple controllers in the Angular app .
我正在使用 Visual Studio 和 Cordova 来编写应用程序。
在同事和 StackOverflow 的大力帮助下,我现在在我的单页移动应用程序中使用了多个 Angular 模式。 (还有另一个关于多模态的 StackOverflow 问题,但它没有告诉您如何使用 http 响应数据。为此,您需要使用 Angular bootstrap。
(这是“提出你的问题并自己回答”的帖子之一 - 但欢迎进一步的建议。)
最佳答案
$uibModal.open
可以接受 resolve
参数,您可以传递 pageData
等参数,用从服务器接收到的数据来解析它。例如
$uibModal.open({
templateUrl: ..,
controller: 'modalCtrl',
resolve: {
pageData: function () {
return $http.get(..).then(function (response) {
return response.data;
});
}
}
});
..
// then inject it in your modal controller
myapp.controller('modalCtrl', ['$scope', 'pageData', function ($scope, pageData) {
$scope.pageData = pageData;
}])
关于javascript - 让多个 Angular 模态处理 http 响应数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39292399/