batmaniac7
batmaniac7

Reputation: 422

Angular: Call Modal in different file

I have a modal which can be called from different pages. So, I need that in different HTML and JS files.

fileA.html and fileA.js are main while fileB.html and fileB.js have the modal. When I am trying to call it I am getting error.

fileA.html

<button type="button" class="btn btn-success" ng-click='openModal()' ><i class="fa fa-sign-out"></i>Modal</button>

fileA.js

angular.module('query').controller('Modal2Ctrl', function ( .... ){
$scope.openModal = function (){

    var modalInstance = $modal.open({
        templateUrl: '/#/data/modal/modal1.html',
        windowClass: 'modal',
        controller: 'ModalCtrl',
        resolve: {
            object : $scope.qid,
        }
    });
 };
 }

fileB.html:

<div ng-controller=""> or <script type="text/ng-template" id="modal.html">
    <!-- Modal Header -->
    <!-- Modal Body -->
    <!-- Modal Footer -->

fileB.js

angular.module('export').controller('Modal1Ctrl', function ($scope, $rootScope, $modal, $log, $compile, $timeout, $modalInstance, ...){ ... }

I would like to use fileB.html and fileB.js on different pages. Any advice on how to call the modal?

Upvotes: 1

Views: 7153

Answers (1)

batmaniac7
batmaniac7

Reputation: 422

http://weblogs.asp.net/dwahlin/building-an-angularjs-modal-service Thanks to @ TechMa9iac for the advice.

Upvotes: 1

Related Questions