Giter Club home page Giter Club logo

Comments (9)

floydwch avatar floydwch commented on July 18, 2024

Do you mean https://github.com/floydsoft/angular-underscore#load-api-only ?

from angular-underscore.

sandrocsimas avatar sandrocsimas commented on July 18, 2024

Yes, but how to use ?

from angular-underscore.

ralyodio avatar ralyodio commented on July 18, 2024

I ended up just doing this:

    .run(function ($rootScope, $location, Auth) {

        //expose lodash to templates
        $rootScope._ = _;

        });
    });

from angular-underscore.

sandrocsimas avatar sandrocsimas commented on July 18, 2024

Another way:

var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
    return window._;
});  

from angular-underscore.

screendriver avatar screendriver commented on July 18, 2024

Can this be done in the angular-underscore library? I would like to use it like so:

angular.module('myApp', ['angular-underscore'])
.controller('MyCtrl', function($scope, _) {

});

from angular-underscore.

jarcoal avatar jarcoal commented on July 18, 2024

It does seem a little silly that you can't just have underscore injected into a controller.

@floydsoft would it be reasonable to add in something like this:

.constant('_', _)

I could submit a PR if you'd accept it.

from angular-underscore.

floydwch avatar floydwch commented on July 18, 2024

@chovy @sandro-csimas @screendriver : Oops, I finally found that I forgot adding document of how to access the underscore utilities from controller, in the current version, the utilities is bound on the $rootScope which means we can access the functions of underscore by $scope such as:

angular.module('myApp', ['angular-underscore'])
.controller('MyCtrl', function($scope) {
    $scope.sample([1, 2, 3]); // got 1, or 2, or 3.
    $scope._([1, 2, 3]); // underscore's chain, http://underscorejs.org/#chain
});

from angular-underscore.

floydwch avatar floydwch commented on July 18, 2024

@jarcoal PR is welcome!

from angular-underscore.

sandrocsimas avatar sandrocsimas commented on July 18, 2024

Thanks @floydsoft, i will check later!

from angular-underscore.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.