0

When I add the "underscore.string" library in my controller everything in the page disappears. I used this thread on stackoverflow to inject underscore to my controller.

This is my controller:

var underscore = angular.module('underscore', []);
underscore.factory('_', ['$window', function($window) {
  return $window._; // assumes underscore has already been loaded on the page
}]);

angular.module('weatherApp', ['underscore'])
  .controller('MainCtrl', ['$scope', '$log', 'weatherService','_', function ($scope, $log, weatherService, _) { //controller code}

I have a main index.html and a main.html. main html is inside of a div in index.html.

What might be the problem? There are no errors on the console.

1
  • have you added ng-app="weatherApp" to your page? Commented Sep 6, 2015 at 13:07

1 Answer 1

1

There's nothing wrong with the code you've provided, it's probably in your HTML, which you must make sure has all the tags closed.

Here's a sample on plunkr

http://embed.plnkr.co/O34NTqMs33IGYbGJXM5U

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.