我在Plunkr中有以下代码。 http://plnkr.co/edit/8sBafktFzFa8fCLLJgMF
这是我的js文件
angular.module('ui.bootstrap.demo', ['ui.bootstrap']);
angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $modal, $log) {
$scope.open = function (size) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent.html',
controller: 'ModalDemoCtrl',
size: size
});
var applicantID = 12;
};
$scope.submit_info = function (size) {
var modalInstance = $modal.open({
templateUrl: 'myModalContent1.html',
controller: 'ModalDemoCtrl',
size: size
});
};
});
这是我的html页面
<!doctype html>
<html ng-app="ui.bootstrap.demo">
<head>
<script src="//ajax.googleapis.com/ajax/libs/angularjs/1.2.16/angular.js"></script>
<script src="//angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.12.0.js"></script>
<script src="example.js"></script>
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div ng-controller="ModalDemoCtrl">
<script type="text/ng-template" id="myModalContent.html">
<h3>I'm a modal!</h3>
<button class="btn btn-default" ng-click="submit_info('lg')">Submit</button>
</script>
<script type="text/ng-template" id="myModalContent1.html">
<h3>CaseID: </h3>
{{ applicantID }}
</script>
<button class="btn btn-default" ng-click="open()">Set caseID</button>
</div>
</body>
</html>
我希望能够在点击按钮&#34; setID&#34;后指定applicantID。点击按钮&#34;提交&#34;,它显示传递的申请人ID值,即&#39; 12&#39;。但它不断传递空数据。
答案 0 :(得分:0)
你需要ng-app,并删除这个$ modal,我修复了你的小提琴:
http://jsfiddle.net/u0nhwa4w/2/
angular.module('loanstreetIpadAppApp',[])
.controller('Mortgage_LoanCtrl', function ($location, $scope, $http, $sce) {
var applicantID;
$scope.submit_info = function() {
applicantID = 12;
getusercaseID(applicantID);
};
var getusercaseID = function(id) {
$scope.page_data = id;
console.log("yes come on ");
console.log($scope.page_data);
};
});