在模式弹出窗口angularjs中打印自定义函数响应
如何在模式弹出窗口中打印我的响应 我有一个不同的开放模态函数&我的自定义函数 我想在模式弹出窗口中打印自定义函数响应在模式弹出窗口angularjs中打印自定义函数响应,angularjs,Angularjs,如何在模式弹出窗口中打印我的响应 我有一个不同的开放模态函数&我的自定义函数 我想在模式弹出窗口中打印自定义函数响应 $scope.createUser = function() { var modalInstance = $modal.open({ templateUrl: '/js/modal-popup.html', controller: function ($scope, $modalInstance, $log) {
$scope.createUser = function() {
var modalInstance = $modal.open({
templateUrl: '/js/modal-popup.html',
controller: function ($scope, $modalInstance, $log) {
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
},
});
}
$scope.allTest = function() {
$http({
method: 'GET',
url: 'api/url'
}).success( function (data) {
$scope.data = data.data;
}).error(function (response){
console.log("error");
});
}
<button type="button" name="createUser" class="btn btn-primary pull-right" ng-click="createUser(); allTest()">Create User </button>
<div class="modal-header">
<h3 class="modal-title"><span class="glyphicon glyphicon-user"></span> Create User</h3>
</div>
<div class="modal-body">
{{data}}
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
<button class="btn btn-warning" ng-click="cancel()">Cancel</button>
</div>
$scope.createUser=function(){
var modalInstance=$modal.open({
templateUrl:“/js/modal popup.html”,
控制器:函数($scope、$modalInstance、$log){
$scope.cancel=函数(){
$modalInstance.disclose('cancel');
};
},
});
}
$scope.allTest=函数(){
$http({
方法:“GET”,
url:'api/url'
}).成功(功能(数据){
$scope.data=data.data;
}).错误(功能(响应){
控制台日志(“错误”);
});
}
创建用户
创建用户
{{data}}
好啊
取消
似乎您正在为您的模式使用angularStrap,在这种情况下,您可以使用resolve属性
var modalInstance = $modal.open({
templateUrl: '/js/modal-popup.html',
controller: function ($scope, $modalInstance, $log) {
$scope.cancel = function () {
$modalInstance.dismiss('cancel');
};
},
resolve: {yourresult: $http({
method: 'GET',
url: 'api/url'
})}
});
注意:仅当承诺解决时,模式才会打开
在弹出窗口中如何调用您的意思是什么?如何在弹出窗口中打印您的结果响应阅读包含依赖项的docs:Object,当所有依赖项都已解决时,这些依赖项将被注入控制器的构造函数中。如果承诺被拒绝,控制器将不加载。你唯一需要的就是把你的范围写出来。。。