AngularJS: External Modal Templates

a 夏天 提交于 2019-12-08 05:03:30

I've done this plnkr so as to explain it better

To open the modal defined in a dedicated html template :

1. The following is declared in the controller responsible for the button opening the modal :

$modal.open({
  templateUrl: 'myModalTemplate.html',
  controller: 'MyModalController'
});

2. This is in the controller of the modal :

$scope.ok = function () {
    $modalInstance.close();
};

$scope.cancel = function () {
    $modalInstance.dismiss('cancel');
};

See also ui bootstrap doc

Please take look the documentation carefully here

You can do something like this with templateUrl

var modalInstance = $modal.open({
      animation: $scope.animationsEnabled,
      templateUrl: 'myModalContent.html',
      controller: 'ModalInstanceCtrl',
      size: size,
      resolve: {
        items: function () {
          return $scope.items;
        }
      }
    });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!