Stack Overflow is a community of 4.7 million programmers, just like you, helping each other.

Join them; it only takes a minute:

Sign up
Join the Stack Overflow community to:
  1. Ask programming questions
  2. Answer and help your peers
  3. Get recognized for your expertise

I have an application with my views in CI folder.

domain.com/apps/view/user/xxx.php

I put Angular on

domain.com/apps/assets/js/app.js

domain.com/apps/assets/js/controllers.js

Currently I am using a static URL to load my view in this application. I use CI Controller for database processing and Angular Controller and Route to display and process the info in the interface.

I face issues when a backup domain is added.

app.js

 angular.module('starter', ['ionic', 'starter.controllers'])

 .run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {         
if (window.cordova && window.cordova.plugins.Keyboard) {
  cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
  StatusBar.styleDefault();
}
  });
})

  .config(function($stateProvider, $urlRouterProvider,$location) {
  $stateProvider

  .state('app', {
url: "/app",
abstract: true,
templateUrl: "http://m.domain.com/_aps4497/views/user/menu.php",
controller: 'AppCtrl'
 })

   .state('app.main', {
url: "/main",
views: {
  'menuContent': {
    templateUrl:  "http://m.domain.com/_aps4497/views/user/main.php"
  }
}
 })

  .state('app.message', {
url: "/message",
views: {
  'menuContent': {
       templateUrl: "http://m.domain.com/_aps4497/views/user/message.php"
  }
}
 })



  $urlRouterProvider.otherwise('/app/main');
});

I tried :

  .state('app.message', {
url: "/message",
views: {
  'menuContent': {
       templateUrl: "http://"+$location.host()+"/_aps4497/views/user/message.php"
  }
}
 })

error : it is retrieved the same .

.config(function($stateProvider, $urlRouterProvider,$location) {
     $stateProvider

   .state('app', {
url: "/app",
abstract: true,
templateUrl: "http://"+$location.host()+"/_aps4497/views/user/menu.php",
controller: 'AppCtrl'
   })

https://docs.angularjs.org/error/$injector/modulerr?p0=starter&p1=$location%20is%20not%20defined <br>

controller.js

 angular.module('starter.controllers', ['pascalprecht.translate'])

.factory('UserService', function($http) {
var data;   
      return{
          getData: function($http) {
                    return $http.get("http://m.domain.com/user/getUserInfo").
                    success(function(response) {
                     /// console.log(JSON.stringify(response));
                      userData=response.data;
                            return userData;

                   }).error(function(data, status, headers, config) {
                     // log error
                    });
          }
    }
})
  1. How do we set the route and location to be dynamic (multiple domain)?

  2. Whats the best practice for the folder system on Angular + CI? if i want to put all my views in the partial folder, where should I put the partial folder to be possibly accessed by Angular controller and app.s?

Please help! Thanks.

share|improve this question

You seems to have not injected the $location before using it..

.config(function($stateProvider, $urlRouterProvider,$location)

and the use it:

templateUrl: "http://"+$location.host()+"/_aps4497/views/user/message.php"
share|improve this answer
    
hi I forgot to update the question. i have injected $location but it still has the same error. – xyonme Jun 1 '15 at 5:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.