Handle errors in Angular UI Router - angularjs

On server side i have a next method, which check if token found in database:
def method(token)
if (Database.find(token).length == 0)
not_found()
else
success()
end
url as token/:token, for example token/123
I have a state for it:
$stateProvider.state('token', {
url: '/token/:token',
templateUrl: 'success'
}).state('404', {
url: '/404',
templateUrl: 'notfound'
});
But i do not know, how to in ui router check token, i need some like this
$http.post('/token', {token: $stateParams.token}).success(function(){
//ok continue and load `success` template
}).error(function(){
$state.go('404'); //when error
});
Is it possible with ui router?

I also had the same situation, This is what I did
.when('/beacon/:beacon_id',{
templateUrl : 'components/beacon/beacon.html',
controller : 'beaconController',
access : { requiredLogin: true },
resolve : {
Beacon : ['$route', 'BeaconService', function($route, BeaconService){
var beacon = BeaconService.beacon();
return beacon.get({'beacon_id':$route.current.params.beacon_id}, function(successResponse){
console.log(successResponse.result[0]);
return successResponse.result[0];
}, function(errorResponse){
$location.path('blablabla'); // This will redirect me to 404. :P
});
}]
}
})
.otherwise({templateUrl : '404.html'});
In controller
App.controller('beaconCtrl', ['Beacon', '$scope', function(Beacon, $scope){
//Get Beacon into controller than get your promise.
Beacon.$promise.then(function(data){
$scope.beacon = data.result[0];
});
}]);

Related

How to supply the separate `template` when param exist?

I have a scenario, to handle the params. ( when param exist it will handled differently )
so, how can i keep 2 templates and use them according to the requirement? at present I am trying like this, which is not working at all.
any one help me?
my state with 2 template: ( please help me to correct )
.state('serialCreateCase', {
url: '/serialCreateCase?sn=',
views:{
"" : {
"templateUrl": 'app/login/loginWithSerial.html'
},
"?sn=" : {
"templateUrl": 'app/login/login.html'
}
}
})
here is the redirection with 2 scenarios: ( correct me if I am wrong )
if(!$rootScope.isUserLoggedIn && toParams.sn !== undefined ) {
console.log('dont take action', toState, toParams.sn );
$rootScope.canNavigate = true;
$state.go('serialCreateCase'); //works
$state.go('serialCreateCase', {sn:'1234'}); //not works
event.preventDefault();
return;
}
There is a working plunker
I would say that you need replace templateUrl with
Templates
TemplateUrl ...
templateUrl can also be a function that returns a url. It takes one preset parameter, stateParams, which is NOT
injected.
TemplateProvider
Or you can use a template provider function which can be injected, has access to locals, and must return template HTML,
like this...
There are more details and plunkers
Angular UI Router: decide child state template on the basis of parent resolved object
dynamic change of templateUrl in ui-router from one state to another
This I prefer the most
...
templateProvider: [$stateParams, '$templateRequest',
function($stateParams, templateRequest)
{
var tplName = "pages/" + $stateParams.type + ".html";
return templateRequest(tplName);
}
],
(check it here) because it uses also $templateRequest
EXTEND
There is a working plunker
this could be the state def
.state('serialCreateCase', {
url: '/serialCreateCase?sn',
views: {
"": {
templateProvider: ['$stateParams', '$templateRequest',
function($stateParams, templateRequest) {
var tplName = "app/login/loginWithSerial.html";
if($stateParams.sn){
tplName = "app/login/login.html";
}
return templateRequest(tplName);
}
]
},
}
});
what we really need is to always pass some value, as sn. So, these should be the calls:
// we need to pass some value, to be sure that there will be other than last
<a ui-sref="serialCreateCase({sn: null})">
// here is reasonable value
<a ui-sref="serialCreateCase({sn:'1234'})">
Check it here in action
use, $stateParams instead of toParams,
1) Deciding the template depending on the param(your requirement)
.state('serialCreateCase', {
url: '/serialCreateCase?sn=',
views: {
'': {
templateUrl: function(stateParams) {
var param = stateParams.sn
return (param == undefined) ? 'app/login/loginWithSerial.html' : 'app/login/login.html'
},
controller: 'myController',
}
}
})
You can check the stateParam using the parameter of templateUrl, and change the templates.
2) change the state depending on the param from controller.
This is a sample controller where you can check the state parameter and use the re directions as your wish.
allControllers.controller('myController', ['$scope','$rootScope','$state','$stateParams',
function($scope,$rootScope,$state,$stateParams) {
if(!$rootScope.isUserLoggedIn)
{
if($stateParams.sn !== undefined )
{
alert('dont take action', $stateParams.sn );
}
else
{
alert('You can redirect, no parameter present');
}
}
}
}])

How to load Angular-translate before any UI is displayed with ui-router resolve

I used angular-translate for i18n. I want to use $translatePartialLoader service to modular language key as lazy load. Also I want to use ui-router resolve option for this.
Now How to do this? Is possible add a code sample for me?
Thanks
I find solutions and solve my problem.
In config:
$translatePartialLoaderProvider.addPart('index');
$translateProvider
.useSanitizeValueStrategy(null)
.fallbackLanguage('en-us')
.registerAvailableLanguageKeys(['en-us','pt-br'], {
'en_*': 'en-us',
'pt_*': 'pt-br'
})
.useLoader('$translatePartialLoader', {
urlTemplate: '{part}/locale_{lang}.json'
})
.useLoaderCache(true)
.useCookieStorage()
.determinePreferredLanguage();
In ui-router for index:
.state('index', {
url: '/index',
templateUrl: 'index.html',
controller:'IndexCtrl',
resolve: {
trans:['RequireTranslations',
function (RequireTranslations) {
RequireTranslations('index');
}],
dep: ['trans','$ocLazyLoad',
function(trans,$ocLazyLoad){
return $ocLazyLoad.load(['plugin']).then(
function(){
return $ocLazyLoad.load(['IndexCtrl.js']);
}
);
}]
}
})
.state('index.users',{
url: "/users",
templateUrl: "users.html",
controller:'UserListCtrl',
resolve: {
trans:['RequireTranslations',
function (RequireTranslations) {
RequireTranslations('modules/user');
}],
dep: ['trans','$ocLazyLoad',
function(trans,$ocLazyLoad){
return $ocLazyLoad.load(['UserListCtrl.js'])
}]
}
})
and in run:
app.run(function($rootScope,$translate) {
// translate refresh is necessary to load translate table
$rootScope.$on('$translatePartialLoaderStructureChanged', function () {
$translate.refresh();
});
$rootScope.$on('$translateChangeEnd', function() {
// get current language
$rootScope.currentLanguage = $translate.use();
});
})
and in RequireTranslations factory:
app.factory('RequireTranslations', function($translatePartialLoader, $translate,$rootScope) {
return function() {
angular.forEach(arguments, function(translationKey) {
$translatePartialLoader.addPart(translationKey);
});
return $translate.refresh().then(
function(){
return $translate.use($rootScope.currentLanguage);
}
);
};
});
and please note you should add $translatePartialLoader and trans as parameter in all controllers like this:
app.controller('UserListCtrl',function($scope,...,$translatePartialLoader,trans){

angularjs state parameters not working

I'm having an issue trying to pass a parameter object to a state using stage.go().
Here is my state definition:
.state('drillhole.ddhinttype', {
url: '/ddhinttype',
templateUrl: VIRTUAL_DIR_PATH + '/App/Views/drillholemanager/drillhole/tabddhinttype.html?v=' + fileVer,
controller: 'DrillHoleDdhIntTypeController',
params: { name: null, description: null }
})
And here is my controller:
try {
angular.module('centric.drillhole.manager');
} catch (e) {
angular.module('centric.drillhole.manager', ['app.config', 'ui.router', 'kendo.directives', 'ui.bootstrap', 'ngCookies', 'centric.common', 'centric.notification', 'pascalprecht.translate', 'centric.security', 'centric.app.settings']);
}
angular.module('centric.drillhole.manager').controller('DrillHoleDdhIntTypeController', ['$scope', 'CentricUIHelper', 'NumberHelper', 'DrillHoleManagerService', 'app.config', '$stateParams',
function ($scope, uihelper, numberHelper, service, appconfig, $stateParams) {
$scope.loading = false;
$scope.isbusy = function () {
return $scope.loading || $scope.$parent.loading;
}
var load = function () {
var hello = $stateParams.name;
var hello2 = $stateParams.description;
};
load();
}]);
And I'm calling the state like so:
$state.go('drillhole.ddhinttype', { name: tab.params.name, description: tab.params.description });
In my controller the name and description properties are always null.
Not sure what I'm missing here. Any ideas?
If you put the params in your url you will be able to access it in controller using $stateParams
.state('drillhole.ddhinttype', {
url: '/ddhinttype/:name/:description',
templateUrl: VIRTUAL_DIR_PATH + '/App/Views/drillholemanager/drillhole/tabddhinttype.html?v=' + fileVer,
controller: 'DrillHoleDdhIntTypeController',
params: { name: null, description: null }
})
You can read more about url routing here: https://github.com/angular-ui/ui-router/wiki/url-routing
Try this in the state definition:
params: { name: undefined, description: undefined }
or this:
params: ['name', 'description']
I feel like I should post the final result. I have decided to pass the parameter in the URL so that I can re-use the same controller for several tabs which each have the same functionality but against different tables in the DB.
Here is the part of my base controller which creates the tabs (CoreLogController.js):
service.getDrillHoleIntervalTypes()
.success(function (res) {
$scope.data.drillHoleIntervalTypes = res;
for (var i = 0; i < $scope.data.drillHoleIntervalTypes.length; i++) {
// add the tab and set it as active if we're in the correct $state
$scope.dynamictabs.push({ heading: $scope.data.drillHoleIntervalTypes[i].Name, route: 'drillhole.ddhinttype', params: { ddhinttype: $scope.data.drillHoleIntervalTypes[i].Name }, active: ($scope.$state.params.ddhinttype == $scope.data.drillHoleIntervalTypes[i].Name) });
}
})
.error(function (error) {
uihelper.showError(error);
});
And here is the relevant HTML portion where the tabs are shown (corelog.html):
<tabset>
<tab ng-repeat="t in statictabs" heading="{{t.heading}}" ui-sref="{{t.route}}" active="t.active"></tab>
<tab ng-repeat="t in dynamictabs" heading="{{t.heading}}" ui-sref="drillhole.ddhinttype({ddhinttype: '{{t.params.ddhinttype}}'})" active="t.active"></tab>
</tabset>
And here is where I define the state (app.js):
.state('drillhole.ddhinttype', {
url: '/ddhinttype/{ddhinttype}',
templateUrl: VIRTUAL_DIR_PATH + '/App/Views/drillholemanager/drillhole/tabddhinttype.html?v=' + fileVer,
controller: 'DrillHoleDdhIntTypeController',
params: { ddhinttype: null }
})
I now get access to the ddhinttype variable on each instance of the controller (DrillHoleDdhIntTypeController.js) which tells it which table to perform operations against.
Since ddhinttype is also contained the URL the user can create a bookmark which will bring them right back to the same tab even though they are dynamically generated.

Angularjs - read inside json file

This is my first attempt with angularjs and ionic-framework.
I have an example json file and i'd like to display onscreen some data from it.
The displaying-data bit works, but i'd like to populate a "details" page with some info that are stored as an abject inside the main json file, and i need to use the id from the url to select to display only the data that i need.
Here's some code:
App.js
angular.module('hgapp', ['ionic', 'hgapp.controllers', 'ngResource'])
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('app', {
url: '/app',
abstract: true,
templateUrl: 'templates/menu.html',
controller: 'AppCtrl'
})
.state('app.details', {
url: '/details/:roomID',
views: {
'menuContent': {
templateUrl: 'templates/details.html',
controller: 'DetailsCtrl'
}
}
})
$urlRouterProvider.otherwise('/app/home');
});
Controllers.js
angular.module('hgapp.controllers', ['hgapp.services'])
.controller('AppCtrl', function ($scope, HGJson) {
HGJson.get(function (data) {
$scope.rooms = data.data;
})
})
.controller('DetailsCtrl', function ($scope, $stateParams, HGJson) {
$scope.roomID = $stateParams.roomID;
console.log($stateParams.roomID);
})
services.js
angular.module('hgapp.services', ['ngResource'])
.factory('HGJson', function ($resource) {
return $resource('json/data.json')
});
Data.json (Just a simplified example)
{
tm: 00000000,
errors: 0,
data: {
{id: 0, name: Value 0, url:url-0},
{id: 1, name: Value 1, url:url-1},
{id: 2, name: Value 2, url:url-2}
}
details.html
<ion-view view-title="Details">
<ion-content>
<h1>{{roomID}}</h1>
</ion-content>
In the details page i'm printing the roomID just to see if the controller (detailsCtrl) works, and i have the correct id printed every time. Now, the bit where i'm stuck is how to manipulate the data from HGJson service so that it allows my to print on data from the right room id.
I hope this question is clear enought, if not, feel free to ask for more clarification.
Thanks a lot
EDIT
At the end i solved it adding this to my controller.js file:
.controller('DetailsCtrl', function ($scope, $stateParams, HGJson) {
HGJson.get(function (data) {
angular.forEach(data.data, function (item) {
if (item.id == $stateParams.roomID)
$scope.currentRoom = item;
});
});
})
Just do the same thing as what you're doing in the app controller, but find the room you want in the returned JSON:
HGJson.get(function (data) {
$scope.room = data.data.filter(function(room) {
return room.id == $stateParams.roomID);
})[0];
});
You could also put that filtering functionality in your service, so that in the future, when you have a real dynamic backend, you call a different URL returning only the requested room rather than calling a URL that returns all the rooms.
angular.module('hgapp.services')
.factory('HGJson', function ($http) {
return {
getRooms: function() {
return $http.get('json/data.json').then(function(response) {
return response.data;
});
},
getRoom: function(roomId) {
return $http.get('json/data.json').then(function(response) {
return response.data.data.filter(function(room) {
return room.id == roomID;
})[0];
});
}
};
});
Note that your JSON is invalid: data must be an array, not an object.
In your controller, you will need to create a function to "find" the correct object in your data object.
Try something like this:
$scope.getRoom = function(id) {
for(var i in $scope.rooms) {
if($scope.rooms[i].id === id) {
return $scope.rooms[i];
}
}
};
And you can display it in your DOM:
{{ getRoom(roomID) }}
BUT it would probably be even better to set the current room to a scoped variable instead of running the function every time. So in this case (I strongly recommend), instead of returning $scope.rooms[i], you could set angular.copy($scope.rooms[i], $scope.currentRoom) (this will copy the room into the currentRoom scoped variable) and then use it in the DOM with simply {{ currentRoom }}
Good luck!

Angular-ui-router dependency error

Ok so, for the record, i had a working project, i had to change the grunt workflow of it, and now angular-ui-router throws me an ununderstandable error.
here is what i get when i follow angularjs links :
Failed to instantiate module app due to:
Failed to instantiate module ui.router due to:
Failed to instantiate module ui.router.state due to:
Uncaught Error: [$injector:modulerr]
http://errors.angularjs.org/1.3.15/$injector/modulerr?p0=app&p1=Error%3A%20…Flocalhost%3A8080%2Fapp%2Fcomponents%2Fangular%2Fangular.min.js%3A38%3A135)(anonymous
function) # angular.min.js:6(anonymous function) # angular.min.js:35r
# angular.min.js:7g # angular.min.js:34ab # angular.min.js:38d #
angular.min.js:17uc # angular.min.js:18Jd #
angular.min.js:17(anonymous function) #
angular.min.js:250n.Callbacks.j #
jquery.min.js:2n.Callbacks.k.fireWith # jquery.min.js:2n.extend.ready
# jquery.min.js:2I # jquery.min.js:2
im quite lost, i tryed downgrading to angularjs 1.3.15, didnt bring anything. The order of inclusion of scripts is the following :
components/html5-boilerplate/dist/js/vendor/modernizr-2.8.3.min.js
components/jquery/dist/jquery.min.js
components/highcharts/highcharts.js
components/bootstrap/dist/js/bootstrap.min.js
components/socket.io-client/socket.io.js
components/bootstrap-switch/dist/js/bootstrap-switch.min.js
components/lodash/lodash.min.js
components/gsap/src/minified/TweenMax.min.js
components/gsap/src/minified/easing/EasePack.min.js
components/PreloadJS/lib/preloadjs-0.6.1.min.js
components/humanize-duration/humanize-duration.js
components/momentjs/min/moment-with-locales.min.js
components/angular/angular.min.js
components/angular-ui-router/release/angular-ui-router.min.js
components/angular-cookies/angular-cookies.min.js
components/ng-tags-input.min/ng-tags-input.min.js
components/angular-sanitize/angular-sanitize.min.js
components/angular-animate/angular-animate.js
components/restangular/dist/restangular.min.js
components/angular-fullscreen/src/angular-fullscreen.js
components/angular-bootstrap/ui-bootstrap.min.js
components/angular-bootstrap/ui-bootstrap-tpls.min.js
components/angular-bootstrap-switch/dist/angular-bootstrap-switch.min.js
components/highcharts-ng/dist/highcharts-ng.min.js
components/ng-droplet/dist/ng-droplet.min.js
components/angular-timer/dist/angular-timer.min.js
src/constants-app.js src/app.js
src/admin/admin-controller.js
src/admin/events/events-controller.js
src/admin/moderation/bans-controller.js
src/admin/moderation/message-modal/message-modal-controller.js
src/admin/moderation/moderation-controller.js
src/admin/partners/partners-controller.js
src/admin/reports/reports-controller.js
src/admin/user/invites/invites-controller.js
src/admin/user/linked/linked-accounts-controller.js
src/admin/user/password/password-controller.js
src/admin/user/user-controller.js src/admin/votes/votes-controller.js
src/adminboard/adminboard-controller.js src/root-controller.js
src/shared/alerts/alerts-controller.js
src/shared/alerts/alerts-directive.js
src/shared/clock/clock-directive.js src/shared/crap.js
src/shared/filters/url-filter.js src/shared/main-controller.js
src/shared/modals/confirm-modal-controller.js
src/shared/purchase-credit-modal/purchase-credit-controller.js
src/shared/purchase-modal/purchase-modal-controller.js
src/shared/services/event-service.js
src/shared/services/message-service.js
src/shared/services/modal-helper-service.js
src/shared/services/queue-service.js
src/shared/services/socket-service.js
src/shared/services/user-service.js
src/shared/services/vote-service.js
src/shared/spinner/spinner-directive.js
src/shared/spinner/spinner-service.js
src/wall/bottomOverlay/bottomOverlay-controller.js
src/wall/bottomOverlay/bottomOverlay-directive.js
src/wall/counters/counters-controller.js
src/wall/counters/counters-directive.js
src/wall/messages/messages-directive.js
src/wall/messages/messages-settings-controller.js
src/wall/slideshow/slideshow-directive.js
src/wall/slideshow/slideshow-settings-controller.js
src/wall/topOverlay/topOverlay-controller.js
src/wall/topOverlay/topOverlay-directive.js
src/wall/vote/vote-directive.js src/wall/wall-controller.js
I separated the scrips in interesting blocks. Where i include angular, ui router, and other pieces.
Here is my app.js file content :
// Declare modules.
angular.module('app')
//ui.routes
.config(['$stateProvider','$urlRouterProvider','$locationProvider',function($stateProvider, $urlRouterProvider, $locationProvider) {
"use strict";
$locationProvider.html5Mode(true); //Remove # in angular urls.
$stateProvider
.state('root',{ //here we resolve all the application wide stuff. Like user.
url : '',
controller : 'rootController',
template : '<ui-view id="rootView"></ui-view>',
resolve : {
user : ['Restangular',function(Restangular){
return Restangular.all('users').customGET('self');
}]
}
})
//MODALS
//BUY CREDIT
.state('purchaseCredit',{
url : '/purchaseCredit'
})
.state('slideShowSettings',{
url : '/slideShowSettings'
})
.state('messagesSettings',{
url : '/messageSettings'
})
.state('root.admin',{
url : '/admin',
templateUrl : 'src/admin/admin.html',
controller : 'adminController'
})
//show user account infos, and actions.
.state('root.admin.user',{
url : '/user',
templateUrl : 'src/admin/user/user.html',
controller: 'userController'
})
//edit user password
.state('root.admin.user.password',{
url : '/password',
templateUrl : 'src/admin/user/password/password.html',
controller : 'passwordController'
})
//show invites list.
.state('root.admin.user.invites',{
url : '/invites',
templateUrl : 'src/admin/user/invites/invites.html',
controller : 'invitesController',
resolve : {
invites: ['Restangular', 'user', function (Restangular, user) {
return Restangular.all('invites').getList({parentId : user._id}); //todo limit to my invites.
}]
}
})
//show one invite.
/* .state('root.admin.user.invites.detail',{
url : '/:id',
templateUrl : 'src/admin/user/invites/invite.html',
controller : 'inviteController',
resolve : {
invite : ['$stateParams', function($stateParams){
if(!$stateParams.id){ return {}; }
return Restangular.one('invites',$stateParams.id).get();
}]
}
})*/
/* LINKED ACCOUNTS */
//list of linked accounts ( people who accepted invite )
.state('root.admin.user.linkedAccounts',{
url : '/linkedAccounts',
templateUrl : 'src/admin/user/linked/linkedAccounts.html',
controller : 'linkedAccountsController',
resolve : {
linkedAccounts : ['Restangular', 'user', function (Restangular, user) {
var query = { parent : user._id/*, sort : '_id', limit : 20, skip : 0*/};
console.warn('gonna fetch', query);
return Restangular.all('users').getList(query);
}]
}
})
.state('root.admin.events',{
url : '/events',
templateUrl : 'src/admin/events/events.html',
controller : 'eventsController'
})
.state('root.admin.moderation', {
url: '/moderation',
templateUrl : 'src/admin/moderation/moderation.html',
controller: 'moderationController'
})
.state('root.admin.bans',{
url : '/bans',
templateUrl : 'src/admin/moderation/bans.html',
controller : 'bansController'
})
.state('root.admin.reports',{
url : 'admin.reports',
templateUrl : 'src/admin/reports/reports.html',
controller : 'reportsController'
})
.state('root.admin.votes',{
url : '/votes/:id',
templateUrl : 'src/admin/votes/votes.html',
controller : 'votesController'
})
.state('root.wall',{
url : '/wall/:eventId',
templateUrl : 'src/wall/wall.html',
controller: 'wallController'
})
.state('root.vote',{ //display vote for conference. integration in powerpoint.
url : '/vote/:voteId',
templateUrl : 'src/vote/vote.html',
controller : 'voteController'
})
.state('root.adminboard',{
url : '/adminboard',
templateUrl : 'src/adminboard/adminboard.html',
controller : 'adminBoardController'
});
$urlRouterProvider.otherwise('/admin/events'); //redirect. default to events page.
}])//restangular
.config(['RestangularProvider',function(RestangularProvider) {
"use strict";
RestangularProvider
.setBaseUrl('/api/v1/')
.setRestangularFields({
id: "_id"
})
.setDefaultHeaders({'Content-Type': 'application/json'})
.setRequestInterceptor(function(elem, operation, what) {
if (operation === 'put' || operation === 'post') {
elem._id = undefined;
elem.__v = undefined;
return elem;
}
return elem;
});
}]).run(['Restangular', '$window','socketService', function(Restangular, $window, socketService ){
'use strict';
Restangular.extendModel('events', function(model) {
if(typeof model !== 'object'){ //todo sometimes ( reset ) gives back a non object.
return false;
}
model.isStarted = function() { //adds started method to all events objects.
return (this.startedUntil ? ( (new Date(this.startedUntil).getTime() > Date.now())) : false);
};
model.hasMessages = function(){
return model.config.phone ||((model.counts.sms + model.counts.appli + model.counts.admin) > 0);
};
model.hasPhone = function(){
return (typeof model.config.phone === 'string');
};
model.hasFacebook = function(){
return model.config.facebookAccounts;
};
model.hasTweeter = function(){
return model.config.twitterHashtags.length;
};
model.hasInstagram = function(){
return model.config.instagramHashtags.length;
};
return model;
});
Restangular.extendModel('users', function(model){ //if user has trial offer and event is started.
model.isTrial = function(){
_.filter(model.offers,function(offer){ //todo make this a function of user? (isTrial)
return (offer.type === 'trial' && (new Date(offer.until).getTime() > Date.now()) );
});
};
return model;
});
Restangular.setErrorInterceptor(
function(response, deferred, responseHandler) {
if (response.status === 401) {
console.log("Login required... ");
$window.location.href = '/login';
} else if (response.status === 404) {
console.log("Resource not available...");
} else if (response.status === 500) {
console.log("Response received with HTTP error code: " + response.status );
return true;
} else if (response.status === 403){
return true;
}
return false; // stop the promise chain
}
);/*.setDefaultRequestParams({ socketId : socketService.socket.id});*/
}]).run(['$rootScope','$modal',function($rootScope, $modal){
"use strict";
/**
* Listen to the `$stateChangeStart` event
*/
$rootScope.$on('$stateChangeStart', function (event, toState, toParams) {
//if the new state is not "terms", then ignore it
switch(toState.name){
case 'purchaseCredit' :
// console.warn('opencredit!');
$modal.open({
templateUrl : 'src/shared/purchase-credit-modal/purchase-credit-modal.html',
controller : 'purchaseModalController',
resolve : {
user : function(){return toParams.user; }
}
});
break;
case 'slideShowSettings' :
//console.error('look here toparams',toParams);
$modal.open({
templateUrl : 'src/wall/slideshow/slideshow-settings-modal.html',
controller : 'slideshowSettingsController',
size:'sm'
});
break;
case 'messagesSettings' :
$modal.open({
templateUrl : 'src/wall/messages/messages-settings-modal.html',
controller : 'messagesSettingsController',
size:'sm'
});
break;
default : //its not a modal state.
return;
}
event.preventDefault(); //prevent transition to the modal's state.
});
}]).controller('HelloWorldController', ['$scope', function($scope) {
"use strict";
$scope.greeting = 'Hello World!';
}]);
And here is my constant-app.js content :
angular.module('app', ['ngSanitize', 'ngCookies', 'ngAnimate', 'ui.router', 'highcharts-ng', 'restangular', 'FBAngular', 'ngDroplet', 'ngTagsInput', 'ui.bootstrap', 'ngDroplet', 'frapontillo.bootstrap-switch', 'timer'])
.constant('App.constants.version', '0.2.0');
what could cause this error? im stuck since several days. I tryed commenting out things but error comes back.

Resources