Hypercubed / angular-marked

Markdown in AngularJS using marked.
http://hypercubed.github.io/angular-marked/
299 stars 59 forks source link

Trying to get it working with no bowered angular app: #12

Closed PerfectCarl closed 9 years ago

PerfectCarl commented 9 years ago

Hello,

I'm using your provider with an angular application that doesn't use bower to manage its dependencies.

I installed the file with bower install Hypercubed/angular-marked and copied the files to app/vendor and then followed your instructions.

I'm not sure that I managed to load hc.marked properly because when I run my app I get the dreaded error:

Unknown provider: markedProvider

Here are the important bits of my application:

Do I need to explicitly load the hc.marked module?

Hypercubed commented 9 years ago

Yes, you need to follow step 4 in the readme: Add hc.marked as a module dependency to your app.

This means add hc.marked into the angular.module('myApp' array.

PerfectCarl commented 9 years ago

Thanks for your quick reply.

I tried it. In fact here was the code I wrote:

angular.module('myApp', [
  'ngRoute',
  'ngSanitize',
  'ngTouch',
  'ui.bootstrap',
  'mediaPlayer',
  'izhukov.utils',
  'izhukov.mtproto',
  'izhukov.mtproto.wrapper',
  'myApp.filters',
  'myApp.services',
  /*PRODUCTION_ONLY_BEGIN
  'myApp.templates',
  PRODUCTION_ONLY_END*/
  'myApp.directives',
  'myApp.controllers', 
  'hc.marked'
]).
config(['$locationProvider', '$routeProvider', '$compileProvider', 'StorageProvider', 'markedProvider', function($locationProvider, $routeProvider, $compileProvider, StorageProvider, markedProvider) {

  $compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|blob|filesystem|chrome-extension|app):|data:image\//);
  $compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|file|mailto|blob|filesystem|chrome-extension|app):|data:/);

  if (Config.Modes.test) {
    StorageProvider.setPrefix('t_');
  }

  $routeProvider.when('/', {templateUrl: templateUrl('welcome'), controller: 'AppWelcomeController'});
  $routeProvider.when('/login', {templateUrl: templateUrl('login'), controller: 'AppLoginController'});
  $routeProvider.when('/im', {templateUrl: templateUrl('im'), controller: 'AppIMController', reloadOnSearch: false});
  $routeProvider.otherwise({redirectTo: '/'});

  markedProvider.setOptions({gfm: true});
}]);

And then the app failed to start with the error:

Error: [$injector:modulerr] Failed to instantiate module myApp due to:
[$injector:modulerr] Failed to instantiate module hc.marked due to:
[$injector:nomod] Module 'hc.marked' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

Note the gulp file is fairly complex (at least for a newcomer like me) invoking ng-annotate and other tasks

PerfectCarl commented 9 years ago

More disturbing info: it works locally on chrome, but not on firefox.

Something is rotten in the kingdom of dependency injections

Hypercubed commented 9 years ago

I don't see anything obvious and I'm surprised that it would work in one browser and not the other. Perhaps try referencing the unminified version in index.html since minification is happening in the gulpfile anyway.

PerfectCarl commented 9 years ago

Thanks, you've been very helpful despite this issue not being related to angular-marked or marked whatsoever :) I'll try to fix my gulp setup.

jon-peel commented 7 years ago

Did you get this working? I am not having any luck and seems to be a similar setup.