javascript - Config issues with Factories in app.js & stateProvider -


i trying set factory in app.js of ionic app. have following code should work state provider throwing me off , im not sure states should be. suggested use app.js code factory working leaves no room routes. have tried different variations of following no lck. thnk in advance.

(function() {   'use strict';    angular     .module('starter', []) // in real application should put dependencies.. ['ng...']     //.run(runfunction) // commenting make work here     .controller('mainctrl', mainctrl)     .factory('myservice', myservice);    // commenting make work here..   /*function runfunction($ionicplatform) {     $ionicplatform.ready(function() {       // hide accessory bar default (remove show accessory bar above keyboard       // form inputs)       if (window.cordova && window.cordova.plugins && window.cordova.plugins.keyboard) {         cordova.plugins.keyboard.hidekeyboardaccessorybar(true);         cordova.plugins.keyboard.disablescroll(true);        }       if (window.statusbar) {         // org.apache.cordova.statusbar required         statusbar.styledefault();       }     })   }*/     mainctrl.$inject = ['$scope', 'myservice'];    function mainctrl($scope, myservice) {     function getsuccess(response) {       $scope.items = response.data;     }      function geterror(response) {       console.log('of course error since url invalid, should work valid url!');     }      myservice.getall()       .then(getsuccess)       .catch(geterror);   }    function myservice($http) {     var factory = {       getall: getall     };      return factory;      function getall() {       return $http.get("url"); // -> should url     }   } })();   // dont know config goes?  .config(function($stateprovider, $urlrouterprovider) {    $stateprovider    // setup abstract state tabs directive     .state('tab', {     url: '/tab',     abstract: true,     templateurl: 'templates/tabs.html'   })      .state('login', {       url: "/login",       cache: false,       controller: 'accountctrl',       templateurl: "templates/login.html"     })      .state('list', {       url: "/list",       cache: false,       controller: 'listctrl',       templateurl: "templates/list.html"      })    $urlrouterprovider.otherwise('/tab/dash');  }); 

i don't see have included ui.router in app. work $stateprovider should place ui.router module in depenencies, , should include angular-ui-router.js files in project.

angular     .module('starter', ['ui.router']) // in real application should put dependencies.. ['ng...']     //.run(runfunction) // commenting make work here     .controller('mainctrl', mainctrl)     .factory('myservice', myservice); 

ui.router module provides $stateprovider.

after .config can go along module .controller , .factory. config defined on app:

angular.module('starter', ['ui.router'])          .config(configfn) //configfn function have in .config         .controller('mainctrl', mainctrl)         .factory('myservice', myservice); 

Comments