AngularJS/HTML-尝试在自定义指令中转义close标记

AngularJS/HTML-尝试在自定义指令中转义close标记,html,angularjs,bootstrap-modal,bootbox,html-escape-characters,Html,Angularjs,Bootstrap Modal,Bootbox,Html Escape Characters,我想看看是否有一种很好的方法可以使用一个自定义的指令来选择地址 下面是一个基本示例 <button class="btn btn-lg btn-primary" ng-bootbox-title="A cool title!" ng-bootbox-custom-dialog="<h1>zzzzzzzzzzzzzzz!</h1>" ng-bootbox-buttons="customDialogButtons"

我想看看是否有一种很好的方法可以使用一个自定义的指令来选择地址

下面是一个基本示例

  <button class="btn btn-lg btn-primary" 
      ng-bootbox-title="A cool title!"
      ng-bootbox-custom-dialog="<h1>zzzzzzzzzzzzzzz!</h1>"
      ng-bootbox-buttons="customDialogButtons"
      ng-bootbox-options="dialogOptions">
          Custom dialog with template
  </button>
我最终想这样做:

ng-bootbox-custom-dialog="<qas-modal-find-postcode address='record.address' town='record.town' county='record.County' post-code='record.postcode'></qas-modal-find-postcode>"
ng引导盒自定义对话框=“”
按钮在模态中加载指令,我有一些双向绑定要处理

我想知道一个很好的方法。我没有使用引导模式,因为多个ID相同时会出现一些冲突

普朗克:


根据您的小提琴,我更改了一些打字错误,并编辑了您的
$ngBootbox
指令,如下所示:

普朗克:

主ajs文件:

angular.module('myapp', ['ngBootbox'])
    .controller('myappController', function($scope) {

        $scope.record = {};
        $scope.record.Country = "UK";
        $scope.record.postcode = "SW12 4RT";
        $scope.record.County = "Some county";
        $scope.record.town = "some town";

    })
    .directive('qasModalFindPostcode', function () {
   return {
       templateUrl: 'tmplModalQasPostcode.html',
       restrict: 'E',
       scope: {
           postCode: '=',
           address: '=',
           town: '=',
           county: '='
       },
       link: function (scope, element, attrs) {

               scope.doSearch = function () {
                 alert(scope.modelTest)
                 console.log(scope);
                  scope.modelTest = "some text"
               }
      }
   }
}))

模式模板
tmplModalQasPostcode.html

<div>
    <button ng-click="doSearch('test')">dsdffsdfsd</button>
    <input type="text" ng-model="modelTest">
    {{modelTest}}
</div>

希望它能帮助您

这方面的一个示例是great@ManuelMiranda你说得很对。我会设置一个。嘿,娜达,你的代码可以工作,但我现在唯一的问题是没有双向绑定。我不知道这是否可能,但这正是我试图做的。按钮事件处理程序只是一个简单的例子。您到底需要什么?我想要双向绑定,因为它是一个指令。例如,指令的父级设置了一些数据,我希望通过指令传递这些数据,并将其放在模式上。有可能吗?再看一眼那辆破车。这就是你需要的吗?是的,太好了。谢谢你!你想更新你的帖子吗?我会接受的。
angular.module('myapp', ['ngBootbox'])
    .controller('myappController', function($scope) {

        $scope.record = {};
        $scope.record.Country = "UK";
        $scope.record.postcode = "SW12 4RT";
        $scope.record.County = "Some county";
        $scope.record.town = "some town";

    })
    .directive('qasModalFindPostcode', function () {
   return {
       templateUrl: 'tmplModalQasPostcode.html',
       restrict: 'E',
       scope: {
           postCode: '=',
           address: '=',
           town: '=',
           county: '='
       },
       link: function (scope, element, attrs) {

               scope.doSearch = function () {
                 alert(scope.modelTest)
                 console.log(scope);
                  scope.modelTest = "some text"
               }
      }
   }
<div>
    <button ng-click="doSearch('test')">dsdffsdfsd</button>
    <input type="text" ng-model="modelTest">
    {{modelTest}}
</div>
customDialog: function (options) {
        if (options.templateUrl) {
          getTemplate(options.templateUrl)
            .then(function (template) {
              options.scope = options.scope || $rootScope;
              options.message = $compile(template)(options.scope);
              $window.bootbox.dialog(options);
            })
            .catch(function () {
              $window.bootbox.dialog(options);
            });
        }
        else {
          options.scope = options.scope || $rootScope;
          options.message = $compile(options.message)(options.scope);
          $window.bootbox.dialog(options);
        }
      },