从ng-template访问范围

Ell*_*one 2 html javascript angularjs ng-dialog

使用AngularJS,我想从a里面访问范围变量<script type="text/ng-template".

<script type="text/ng-template" id="firstDialogId">
    <div class="ngdialog-message" align="center" id="download">
        <h4 ng-show=isFrench>Télécharger la cartographie</h4>
        <h4 ng-show=isEnglish>Download cartography</h4>
        <a href="../downloads/PDF/{{currentLanguage}}/{{currentCartography}}.pdf" download>
            <img  src="../style/images/pdf-icon.png" alt="Download PDF" width="30%" height="30%">
        </a>   
        <a href="../downloads/VSD/{{currentCartography}}.vsd" download>
            <img border="0" src="../style/images/vsd-icon.png" alt="Download VSD" width="30%" height="30%">
        </a>   
        <a href="../downloads/PNG/{{currentLanguage}}/{{currentCartography}}.png" download>
            <img border="0" src="../style/images/PNG-icon.png" alt="Download PNG" width="30%" height="30%">
        </a>   

         <div class="ngdialog-buttons">
             <button type="button" class="ngdialog-button ngdialog-button-primary" ng-click="closeThisDialog('button')">Close</button>
         </div>
    </div>
</script>
Run Code Online (Sandbox Code Playgroud)

isFrench并且isEnglish是来自我的控制器的2个布尔值.

相同的currentCartographycurrentLanguage,它们是我的控制器的字符串.

我也尝试了控制器内外的getter,结果相同.

Ell*_*one 5

对于那些陷入同一问题的人:

使用ngDialog,我们需要精确地使用范围.在我的情况下,我在控制器中添加了对话框打开功能,我需要编辑我正在使用的那个以便scope: $scope,按如下方式添加行:

$scope.openPlainCustomWidth = function () {
    $rootScope.theme = 'ngdialog-theme-plain custom-width';
    ngDialog.open({
        template: 'firstDialogId',
        controller: 'InsideCtrl',
        className: 'ngdialog-theme-plain custom-width',
        scope: $scope, // this line wasn't here before
        closeByDocument: false
    });
};
Run Code Online (Sandbox Code Playgroud)