GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Modal unknown provider · Issue #2247 · angular-fullstack/generator-angular-fullstack

This repository was archived by the owner on Jul 29, 2026. It is now read-only.
This repository was archived by the owner on Jul 29, 2026. It is now read-only.

Modal unknown provider #2247

Copy link
Copy link
Closed
Closed
Modal unknown provider#2247
Copy link

Description

@hopeworkscamden
hopeworkscamden
opened on Sep 20, 2016
Issue body actions
  • I understand that GitHub issues are not for tech support, but for questions specific to this generator, bug reports, and feature requests.
Item Version
generator-angular-fullstack 4.0.4
Node 5.4.0
npm 3.10.7
Operating System cloud9
Item Answer
Transpiler Babel
Markup HTML
CSS SCSS
Router ui-router
Client Tests Mocha
DB MongoDB
Auth Y

I cannot figure out why the Modal service injection is not working. I have added it as a dependency to the app.js and as well have added the dependency to the controller which I would like to use it from. Very desperate to get this working and appreciate anyone who can help me figure this out.

app.js

import _Auth from '../components/auth/auth.module';
import account from './account';
import admin from './admin';
import navbar from '../components/navbar/navbar.component';
import footer from '../components/footer/footer.component';
import main from './main/main.component';
import constants from './app.constants';
import util from '../components/util/util.module';
import socket from '../components/socket/socket.service';
import modal from '../components/modal/modal.service';

import './app.scss';

angular.module('camdenfirstApp', [ngCookies, ngResource, ngSanitize, 'btford.socket-io', uiRouter,
    uiBootstrap, modal, _Auth, account, admin, navbar, footer, main, constants, socket, util, 'leaflet-directive'
  ])
  .config(routeConfig)
  .run(function($rootScope, $location, Auth) {
    'ngInject';
    // Redirect to login if route requires auth and you're not logged in

controller trying to use the Modal

import angular from 'angular';
import uiRouter from 'angular-ui-router';
import routing from './main.routes';

export class MainController {
  $http;
  socket;
  Modal;
  awesomeThings = [];
  newThing = '';
  camden = {autoDiscover:true};
  locFound = false;

  /*@ngInject*/
  constructor($http, $scope, socket, Modal) {
    this.Modal = Modal;
    this.$http = $http;
    this.socket = socket;

    $scope.$on('$destroy', function() {
      socket.unsyncUpdates('thing');
    });

    $scope.delete = this.Modal.confirm.delete()('asdf');

    $scope.events = { // or just {} //all events
                        markers:{
                          enable: [ 'dragend' ]
                          //logic: 'emit'
                        }
                    }

    $scope.camden = {autoDiscover:true};

     $scope.$on('leafletDirectiveMap.locationfound', function(event){
        $scope.eventDetected = "ZoomStart";
         var instancePosition = {
                            lat: $scope.camden.lat,
                            lng: $scope.camden.lng,
                            focus: true,
                            message: "Drag to Flooding Instance",
                            draggable: true
                        };

       $scope.markers = {
                        instancePosition: angular.copy(instancePosition)
                      }
    });

    $scope.$on("leafletDirectiveMarker.dragend", function(event, args){
                $scope.camden.lat = args.model.lat;
                $scope.camden.lng = args.model.lng;
                $scope.markers.instancePosition.lat = args.model.lat;
                $scope.markers.instancePosition.lng = args.model.lng;
            });

  }


  $onInit() {
    this.$http.get('/api/things')
      .then(response => {
        this.awesomeThings = response.data;
        this.socket.syncUpdates('thing', this.awesomeThings);
      });
  }


  addThing() {
    if(this.newThing) {
      this.$http.post('/api/things', {
        name: this.newThing
      });
      this.newThing = '';
    }
  }

  deleteThing(thing) {
    this.$http.delete('/api/things/' + thing._id);
  }
}

export default angular.module('camdenfirstApp.main', [uiRouter])
  .config(routing)
  .component('main', {
    template: require('./main.html'),
    controller: MainController
  })
  .name;

EDIT: if you;d like to see the project itself you can find it here: https://camden-first-hopeworks.c9users.io:8081/

Activity

  1. Awk34 commented on Sep 20, 2016

    @Awk34
    Awk34
    on Sep 20, 2016
    Collaborator
    More actions

    Please surround your different code blocks with triple ticks (```). Your code is quite hard to read as-is.

  2. hopeworkscamden commented on Sep 20, 2016

    @hopeworkscamden
    hopeworkscamden
    on Sep 20, 2016
    Author
    More actions

    @Awk34 sorry about that, I have updated

  3. Awk34 commented on Sep 20, 2016

    @Awk34
    Awk34
    on Sep 20, 2016
    Collaborator
    More actions

    Can you provide a full stack trace as well?

  4. hopeworkscamden commented on Sep 21, 2016

    @hopeworkscamden
    hopeworkscamden
    on Sep 21, 2016
    Author
    More actions

    here is the full error that occurs

    angular.js:13920ReferenceError: Modal is not defined
    at new MainController (https://camden-first-hopeworks.c9users.io:8081/app.bundle.js:1143:19)
    at Object.invoke (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:4845:20)
    at $controllerInit (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:10481:35)
    at nodeLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:9390:35)
    at compositeLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:8747:14)
    at publicLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:8627:31)
    at Object. (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:38087:10)
    at https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:1374:19
    at invokeLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:10061:10)
    at nodeLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:9462:12)
    at compositeLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:8747:14)
    at publicLinkFn (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:8627:31)
    at lazyCompilation (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:8971:26)
    at updateView (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:38005:24)
    at https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:37954:12
    at Scope.$broadcast (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:18132:29)
    at https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:37335:23
    at processQueue (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:16510:29)
    at https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:16526:28
    at Scope.$eval (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:17809:29)
    at Scope.$digest (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:17622:32)
    at Scope.$apply (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:17917:25)
    at bootstrapApply (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:1888:16)
    at Object.invoke (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:4845:20)
    at doBootstrap (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:1886:15)
    at Object.bootstrap (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:1906:13)
    at https://camden-first-hopeworks.c9users.io:8081/app.bundle.js:93:22
    at HTMLDocument.trigger (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:3334:8)
    at defaultHandlerWrapper (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:3624:12)
    at HTMLDocument.eventHandler (https://camden-first-hopeworks.c9users.io:8081/vendor.bundle.js:3612:10)

  5. thedewpoint commented on Sep 21, 2016

    @thedewpoint
    thedewpoint
    on Sep 21, 2016
    More actions

    Can you post what's in modal.service? You're expecting the import to provide you a module name but I'm not sure that's what you're importing

  6. hopeworkscamden commented on Sep 22, 2016

    @hopeworkscamden
    hopeworkscamden
    on Sep 22, 2016
    Author
    More actions
    'use strict';
    
    import angular from 'angular';
    
    export function Modal($rootScope, $uibModal) {
      /**
       * Opens a modal
       * @param  {Object} scope      - an object to be merged with modal's scope
       * @param  {String} modalClass - (optional) class(es) to be applied to the modal
       * @return {Object}            - the instance $uibModal.open() returns
       */
      function openModal(scope = {}, modalClass = 'modal-default') {
        var modalScope = $rootScope.$new();
    
        angular.extend(modalScope, scope);
    
        return $uibModal.open({
          template: require('./modal.html'),
          windowClass: modalClass,
          scope: modalScope
        });
      }
    
      // Public API here
      return {
    
        /* Confirmation modals */
        confirm: {
    
          /**
           * Create a function to open a delete confirmation modal (ex. ng-click='myModalFn(name, arg1, arg2...)')
           * @param  {Function} del - callback, ran when delete is confirmed
           * @return {Function}     - the function to open the modal (ex. myModalFn)
           */
          delete(del = angular.noop) {
            /**
             * Open a delete confirmation modal
             * @param  {String} name   - name or info to show on modal
             * @param  {All}           - any additional args are passed straight to del callback
             */
            return function() {
              var args = Array.prototype.slice.call(arguments);
              var name = args.shift();
              var deleteModal;
    
              deleteModal = openModal({
                modal: {
                  dismissable: true,
                  title: 'Confirm Delete',
                  html: '<p>Are you sure you want to delete <strong>' + name + '</strong> ?</p>',
                  buttons: [{
                    classes: 'btn-danger',
                    text: 'Delete',
                    click(e) {
                      deleteModal.close(e);
                    }
                  }, {
                    classes: 'btn-default',
                    text: 'Cancel',
                    click(e) {
                      deleteModal.dismiss(e);
                    }
                  }]
                }
              }, 'modal-danger');
    
              deleteModal.result.then(function(event) {
                del.apply(event, args);
              });
            };
          }
        }
      };
    }
    
    export default angular.module('workspaceApp')
      .factory('Modal', Modal)
      .name;
    
  7. Azayzel commented on Sep 23, 2016

    @Azayzel
    Azayzel
    on Sep 23, 2016
    Contributor
    More actions

    Your specific issue seems to be case. In your app.js you're importing with lowercase 'm' but in your controller your using it as 'M'. Try fixing it to a capital 'M' when importing and in your injection.

    With that being said; i am also having trouble with this Modal. When i call $uibModal directly from my controller it works the way a Modal should. But not via this service.

    Reacted by Hopeworks
  8. Azayzel commented on Sep 23, 2016

    @Azayzel
    Azayzel
    on Sep 23, 2016
    Contributor
    More actions

    Ive created a PR that fixes this issue. #2256

    The problem lies at the export of the factory. Change

    export default angular.module('workspaceApp')
      .factory('Modal', Modal)
      .name;
    

    to

    export default angular.module('workspaceApp.Modal',[])
      .factory('Modal', Modal)
      .name;
    
    Reacted by Hopeworks, Zane and Andrew Koroluk
  9. Awk34
    closed this as completedin 68b7b69on Sep 26, 2016
  10. hopeworkscamden commented on Sep 26, 2016

    @hopeworkscamden
    hopeworkscamden
    on Sep 26, 2016
    Author
    More actions

    Thanks @Azayzel ! I really appreciate it! Got my first modal to pop up today using the Modal service. Next stop is injecting the controller scope i'm calling the modal from into the modal itself.

    Reacted by Josh Lavely
  11. marwenlandoulsi commented on Dec 29, 2016

    @marwenlandoulsi
    marwenlandoulsi
    on Dec 29, 2016
    More actions

    Please i need help. i have got this bug :

    vendor.bundle.js:14047 Error: [$injector:strictdi] Modal is not using explicit annotation and cannot be invoked in strict mode
    http://errors.angularjs.org/1.5.8/$injector/strictdi?p0=Modal
    at http://localhost:8086/vendor.bundle.js:195:13
    at Function.annotate [as $$annotate] (http://localhost:8086/vendor.bundle.js:4079:18)
    at injectionArgs (http://localhost:8086/vendor.bundle.js:4806:37)
    at Object.invoke (http://localhost:8086/vendor.bundle.js:4837:19)
    at Object.enforcedReturnValue [as $get] (http://localhost:8086/vendor.bundle.js:4684:38)
    at Object.invoke (http://localhost:8086/vendor.bundle.js:4845:20)
    at http://localhost:8086/vendor.bundle.js:4644:38
    at getService (http://localhost:8086/vendor.bundle.js:4791:40)
    at injectionArgs (http://localhost:8086/vendor.bundle.js:4815:59)
    at Object.instantiate (http://localhost:8086/vendor.bundle.js:4857:19)
    at $controller (http://localhost:8086/vendor.bundle.js:10496:29)
    at Object. (http://localhost:8086/vendor.bundle.js:38077:29)
    at http://localhost:8086/vendor.bundle.js:1374:19
    at invokeLinkFn (http://localhost:8086/vendor.bundle.js:10061:10)
    at nodeLinkFn (http://localhost:8086/vendor.bundle.js:9462:12)
    at compositeLinkFn (http://localhost:8086/vendor.bundle.js:8747:14)
    at publicLinkFn (http://localhost:8086/vendor.bundle.js:8627:31)
    at lazyCompilation (http://localhost:8086/vendor.bundle.js:8971:26)
    at updateView (http://localhost:8086/vendor.bundle.js:38005:24)
    at http://localhost:8086/vendor.bundle.js:37954:12
    at Scope.$broadcast (http://localhost:8086/vendor.bundle.js:18132:29)
    at http://localhost:8086/vendor.bundle.js:37335:23
    at processQueue (http://localhost:8086/vendor.bundle.js:16510:29)
    at http://localhost:8086/vendor.bundle.js:16526:28
    at Scope.$eval (http://localhost:8086/vendor.bundle.js:17809:29)
    at Scope.$digest (http://localhost:8086/vendor.bundle.js:17622:32)
    at Scope.$apply (http://localhost:8086/vendor.bundle.js:17917:25)
    at bootstrapApply (http://localhost:8086/vendor.bundle.js:1888:16)
    at Object.invoke (http://localhost:8086/vendor.bundle.js:4845:20)
    at doBootstrap (http://localhost:8086/vendor.bundle.js:1886:15)
    at Object.bootstrap (http://localhost:8086/vendor.bundle.js:1906:13)
    at http://localhost:8086/app.bundle.js:100:22
    at HTMLDocument.trigger (http://localhost:8086/vendor.bundle.js:3334:8)
    at defaultHandlerWrapper (http://localhost:8086/vendor.bundle.js:3624:12)
    at HTMLDocument.eventHandler (http://localhost:8086/vendor.bundle.js:3612:10)

    Any solution ??

  12. zaphinath commented on Apr 24, 2017

    @zaphinath
    zaphinath
    on Apr 24, 2017
    More actions

    I'm seeing the same issue - angular.js:14525 Error: [$injector:strictdi] Modal is not using explicit annotation and cannot be invoked in strict mode.

    Any solution?

  13. thedewpoint commented on Apr 24, 2017

    @thedewpoint
    thedewpoint
    on Apr 24, 2017 via email
    More actions
    Usually that happens when you forget an nginject annotation On Apr 23, 2017 11:15 PM, "Derek Carr" <[email protected]> wrote: I'm seeing the same issue - angular.js:14525 Error: [$injector:strictdi] Modal is not using explicit annotation and cannot be invoked in strict mode. Any solution? — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#2247 (comment)>, or mute the thread <https://github.com/notifications/unsubscribe-auth/ADEBQwQISUfKiYq1nGrqXp4UtRt4xRX2ks5rzBPEgaJpZM4KB7BM> .
  14. zaphinath commented on Apr 24, 2017

    @zaphinath
    zaphinath
    on Apr 24, 2017
    More actions

    #2203 Fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.