i’m having some difficulty getting restangular and lodash integrated with my project.
UPDATE: upon writing this query, i’ve actually found a solution
I’m not sure if you need both lodash and ng-lodash, but i spent a few hours working on this, re-gulping and re-starting my ionic server, and it didn’t work until i had both lodash and ng-lodash. Please let me know if i’m wrong.
Here are my steps:
open terminal in your ionic’s app folder
- npm install --save restangular
- npm install --save lodash
- bower install --save restangular
- bower install --save lodash (you want to pick the version >1.3 but <2.5. )
- bower install --save ng-lodash
within index, replace
<script src="lib/ionic/js/ionic.bundle.js"></script>
with
<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ngCordova/dist/ng-cordova.js"></script> <!--- (you may / may not have this installed) -->
<script src="lib/restangular/dist/restangular.min.js"></script>
<script src="lib/ng-lodash/build/ng-lodash.min.js"></script>
<script src="lib/lodash/dist/lodash.min.js"></script>
<script src="lib/lodash/dist/lodash.underscore.min.js"></script>
In gulpfile.js, add the following at the end of your requires:
var _ = require('lodash');
in app.js, include the libraries at the top:
angular.module('myFirstApp',
[ 'ionic'
, 'ngCordova'
, 'ngLodash'
, 'restangular'
])
You can then go about including it where needed:
.config(function($stateProvider, $urlRouterProvider, $compileProvider, RestangularProvider) {
You can then also include Restangular in your controllers.js
.controller('StatusCtrl', ["$scope", "Restangular", function($scope, Restangular) {
$scope.oranges = Restangular.all("users").getList().$object;
}])
After all of this, make sure you perform the following in your terminal
refresh your Gulp with:
gulp
quit your ionic server and restart it with:
ionic serve [your-port-number]
Good luck!