我正在使用角引導模式。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