我正在使用角引导模式。AngularJS引导模式范围值不显示
termsText
已填充且scope.productTerms
确实包含值。但由于某种原因,当我在模态内输出{{ productTerms }}
时,该值未被显示。为什么?
JS
$scope.openProductTerms = function (termsText) {
$scope.productTerms = termsText <-- has a value in console.log()
var modalInstance = $modal.open({
templateUrl: 'myModalTerms.html',
controller: ModalInstanceCtrl
});
var ModalInstanceCtrl = function ($scope, $modalInstance) {
$scope.ok = function() {
$modalInstance.dismiss('OK');
};
};
HTML
{{ productTerms }} < ==== value shows outside modal
<script type="text/ng-template" id="myModalTerms.html">
<div class="modal-body">
{{ productTerms }} <==== same value does not show insdie modal?
</div>
<div class="modal-footer">
<button class="btn btn-primary" ng-click="ok()">OK</button>
</div>
</script>
模态有一个新的控制器,并因此新的范围。这可能会有所帮助https://egghead.io/lessons/angularjs-sharing-data-between-controllers – user3360944
当您打开模式时,您应该能够指定范围。 –
@Zack Argyle范围是空的。 – Prometheus