Comments (9)
Do you mean https://github.com/floydsoft/angular-underscore#load-api-only ?
from angular-underscore.
Yes, but how to use ?
from angular-underscore.
I ended up just doing this:
.run(function ($rootScope, $location, Auth) {
//expose lodash to templates
$rootScope._ = _;
});
});
from angular-underscore.
Another way:
var underscore = angular.module('underscore', []);
underscore.factory('_', function() {
return window._;
});
from angular-underscore.
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.
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.
@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.
@jarcoal PR is welcome!
from angular-underscore.
Thanks @floydsoft, i will check later!
from angular-underscore.
Related Issues (20)
- How to use it HOT 2
- What license is the angular-underscore project released under? HOT 1
- how to use the filter filter HOT 1
- map as a filter? HOT 1
- Shiv for "sortedIndex"
- Error: $rootScope:infdig Infinite $digest Loop HOT 2
- Newly introduced methods 'indexBy' and 'sample' HOT 1
- Uncaught ReferenceError: _ is not defined HOT 2
- Gem? HOT 5
- Make _.delay(), _.throttle(), and _.debounce() karma friendly HOT 3
- Problem with isolated scope HOT 2
- Registering filters 3 times HOT 1
- Underscore is undefined if I use inside a Directive $scope._
- groupBy filter error HOT 3
- More examples? HOT 1
- Sorry but... HOT 1
- property predicate
- Error on minify HOT 1
- Consider a bower package? HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-underscore.