0

I want to create to a popup to send email ? are you sure you want to send an email yes or no? Please help me out M getting this error Unknown provider: $modalProvider <- $modal <- userDetailController.

define([
    'angular',
    './module'
], function (angular, module) {
    'use strict';

    module.controller('userDetailController', [
        '$scope',
        'userDetails',
        'navigationStateService',
        '$translate',
        'ngDialog',  
        function ($scope,userDetails,navigationStateService, $translate,ngDialog) {

            $scope.user = userDetails.getSelectedUser();



 $scope.openContactForm = function() {

                 var promise = modals.open(
                         "confirm",
                         {
                             message: "Are you sure you want to taste that?!"
                         }
                     );
                 promise.then(
                         function handleResolve( response ) {
                             console.log( "Confirm resolved." );
                         },
                         function handleReject( error ) {
                             console.warn( "Confirm rejected!" );
                         }
                     );
            };
priyanka
  • 422
  • 2
  • 7
  • 19
  • I don't see you adding `$modalProvider` as a dependency. – Clyde Lobo Jul 07 '16 at 07:57
  • 1
    Possible duplicate of [Unknown provider: $modalProvider <- $modal error with AngularJS](http://stackoverflow.com/questions/18733680/unknown-provider-modalprovider-modal-error-with-angularjs) – Clyde Lobo Jul 07 '16 at 07:57
  • this code couldn't generate that error, since you aren't trying to inject `$modal` anywhere, and the code isn't using any service `$modal`. `modals` isn't the same thing at all. – Claies Jul 07 '16 at 08:00
  • I injected modal here module.controller('userDetailController', [ '$scope', 'userDetails', 'navigationStateService', '$translate', 'ngDialog', '$modal', function ($scope,userDetails,navigationStateService, $translate,ngDialog,$modal) { – priyanka Jul 07 '16 at 08:05
  • the code in your comment doesn't match the code in the question body. are you suggesting that you posted the wrong code in the question (which you should edit and correct), or that you added it after posting the question? – Claies Jul 07 '16 at 08:12
  • i added it after posting question here but still m gettting that error – priyanka Jul 07 '16 at 08:14
  • Have you added the js file in your index.html ? Have you added the reference to you app declaration ? – Weedoze Jul 07 '16 at 09:14

1 Answers1

0

Try $uibModal's , it is very simple, example:

angular.module('ui.bootstrap.demo').controller('ModalDemoCtrl', function ($scope, $uibModal, $log) {
  $scope.animationsEnabled = true;
//open modal
  $scope.open = function (size) {

    var modalInstance = $uibModal.open({
      animation: $scope.animationsEnabled,
      templateUrl: 'myModalContent.html',
      controller: 'ModalInstanceCtrl',
      size: size,
      resolve: {
        //resolve
      }
    });

    modalInstance.result.then(function (selectedItem) {
      //.then
    }, function () {
      $log.info('Modal dismissed at: ' + new Date());
    });
  };

  $scope.toggleAnimation = function () {
    $scope.animationsEnabled = !$scope.animationsEnabled;
  };

});
Itsik Mauyhas
  • 3,824
  • 14
  • 69
  • 114