1

Here is my home.html:

<ion-view view-title="Home">
    <ion-content>
        <h1>here is home </h1>
    </ion-content>
</ion-view>

here my app.js:

// Ionic Starter App

// angular.module is a global place for creating, registering and retrieving Angular modules
// 'starter' is the name of this angular module example (also set in a <body> attribute in index.html)
// the 2nd parameter is an array of 'requires'
// 'starter.services' is found in services.js
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic','ionic.service.core', 'starter.controllers', 'starter.services','ui.bootstrap'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for 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();
    }
  });
})


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

  .state('app', {
    url: '/app',
    abstract: true,
    templateUrl: 'templates/menu.html'
  })
  .state('app.home', {
    cache:false,
    url: '/home',
    views: {
      'menuContent': {
        templateUrl: 'templates/home.html',
        controller: 'homeCtrl'
      }
    }
  })
  .state('app.login', {
    url: '/login',
    views: {
      'menuContent': {
        templateUrl: 'templates/form-connection.html',
        controller: 'LoginConnect'
      }
    }
  })
  .state('app.registre', {
    url: '/registre',
    views: {
      'menuContent': {
        templateUrl: 'templates/registre.html',
        controller: 'registreCtrl'
      }
    }
  })
  .state('app.facturer', {
    url: '/facturer',
    views: {
      'menuContent': {
        templateUrl: 'templates/facturer.html',
        controller: 'facturerCtrl'
      }
    }
  })
  .state('app.params', {
    url: '/params',
    views: {
      'menuContent': {
        templateUrl: 'templates/parametres.html',
        controller: 'parametresCtrl'
      }
    }
  })
  .state('app.documents', {
    url: '/documents',
    views: {
      'menuContent': {
        templateUrl: 'templates/documents.html',
        controller: 'documentsCtrl'
      }
    }
  });
  // if none of the above states are matched, use this as the fallback
  $urlRouterProvider.otherwise('/app/home');
});

and here my index.html :

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    <title></title>

    <link href="lib/ionic/css/ionic.css" rel="stylesheet">
    <link href="css/style.css" rel="stylesheet">

    <!-- IF using Sass (run gulp sass first), then uncomment below and remove the CSS includes above
    <link href="css/ionic.app.css" rel="stylesheet">
    -->

    <!-- ionic/angularjs js -->
    <script src="lib/ionic/js/ionic.bundle.js"></script>
    <script src="lib/angular-ui-bootstrap/dist/ui-bootstrap.js"></script>
    <link rel="stylesheet" href="lib/angular-ui-bootstrap/dist/ui-bootstrap-csp.css">
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular-messages.js"></script>

    <link rel="stylesheet" href="lib/angular-ui-bootstrap/dist/bootstrap.min.css">
    <link rel="stylesheet" href="lib/angular-ui-bootstrap/dist/bootstrap-theme.min.css">
    <script src="lib/ionic-platform-web-client/dist/ionic.io.bundle.min.js"></script>



    <!-- your app's js -->

        <!-- ionic/angularjs js -->


        <!-- cordova script (this will be a 404 during development) -->
    <script src="cordova.js"></script>
    <script src="js/app.js"></script>
    <script src="js/controllers.js"></script>
    <script src="js/services.js"></script>

  </head>
  <body ng-app="starter">
    <ion-nav-view></ion-nav-view>
  </body>
</html>

and here the controller :

angular.module('starter', [])

.controller('homeCtrl', function($scope, $stateParams) {

})
.controller('registreCtrl', function($scope, $stateParams) {

})
.controller('facturerCtrl', function($scope, $stateParams) {

})
.controller('documentsCtrl', function($scope, $stateParams) {

})
.controller('parametresCtrl', function($scope, $stateParams) {

})


.config(['$httpProvider', function($httpProvider) {
       $httpProvider.defaults.useXDomain = true;
       delete $httpProvider.defaults.headers.common['X-Requested-With'];
   }
])
//controller pour connection to API
.controller('LoginConnect', ['$scope', 'connecting','sendtoken',
function($scope,connecting,sendtoken){
    $scope.user = {};
    var users = $scope.user;
    $scope.connect = function (users) {
      var log = $scope.user.login;
      var pass = $scope.user.password;
      var mydata = {};
      connecting.login(log,pass).then(function(result){
        console.log(result);
        var montoken = result.data.token;
         sessionStorage.setItem('token',montoken);
         console.log(montoken);
      });


      var mytoken = sessionStorage.getItem('token');
      console.log(mytoken);
       sendtoken.send(mytoken).then(function(userdata){
         $scope.datab = userdata;
       });
    };
  }
])

  //factory pour aller chercher le token
.factory('connecting', ['$http','$q', function ($http,$q){
      var ConnectingFactory = {};
      ConnectingFactory.login = function(log,pass){
       var deferred = $q.defer();
       $http({
           method: 'POST',
           url: "http://api.tiime-ae.fr/0.1/request/login.php",
           headers: {'Content-Type': 'application/x-www-form-urlencoded'},
           transformRequest: function(obj) {
               var str = [];
               for(var p in obj)
               str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
               return str.join("&");
           },
           data: {login: log, password: pass}
           })
       .success(function(result){
          deferred.resolve(result);
          // var promise = deferred.promise;
          // promise.then(function(result){
          // var  mydata = result["data"];
          // console.log(mydata);
          //   }
          //);
        });
        return deferred.promise;
       };
       return ConnectingFactory;

}])
    //END factory pour aller chercher le token

    //Factory pour envoyer le token
    .factory('sendtoken', ['$http','$q', function ($http,$q){
          var tokenreceipt = {};
          tokenreceipt.send = function(mytoken){
           var deferred = $q.defer();
           $http({
               method: 'POST',
               url: "http://api.tiime-ae.fr/0.1/request/settings-get.php",
               headers: {'Content-Type': 'application/x-www-form-urlencoded'},
               transformRequest: function(obj) {
                   var str = [];
                   for(var p in obj)
                   str.push(encodeURIComponent(p) + "=" + encodeURIComponent(obj[p]));
                   return str.join("&");
               },
               data: {token : mytoken}
               })
               .success(function(userdata){
                  deferred.resolve(userdata);
                  // var promise = deferred.promise;
                  // promise.then(function(result){
                  // var  mydata = result["data"];
                  // console.log(mydata);
                  //   }
                  //);
                });
                return deferred.promise;
               };
               return tokenreceipt;
    }]);
      //END Factory pour envoyer le token


;













          //envoie du token

            // var deferredd = $q.defer();
            //
            // $http({
            //     method: 'POST',
            //     url: "http://api.tiime-ae.fr/0.1/request/settings-get.php",
            //     headers: {'Content-Type': 'application/x-www-form-urlencoded'},
            //     data: {token: $scope.user.token}
            //     })
            //     .success(function(mesdatas){
            //       deferredd.resolve(mesdatas);
            //         var promises = deferredd.promises;
            //         promises.then(function(mesdatas){
            //             $scope.datab = mesdatas;
            //               $scope.user.datab = mesdatas["data"];
            //        // jsonTab = angular.fromJson(result);
            //
            //
            //   });
            // })
            //   console.log($scope.user.token);

        //fin envoie token





//user connection

// End of user connection

// .controller('ButtonsCtrl', function ($scope) {
//   $scope.singleModel = 1;
//
//   $scope.radioModel = 'Middle';
//
//   $scope.checkModel = {
//     left: false,
//     middle: true,
//     right: false
//   };
//
//   $scope.checkResults = [];
//
//   $scope.$watchCollection('checkModel', function () {
//     $scope.checkResults = [];
//     angular.forEach($scope.checkModel, function (value, key) {
//       if (value) {
//         $scope.checkResults.push(key);
//       }
//     });
//   });
// })

My issue : i got nothing (white page ) when i go to url : http://localhost:8100/home i only have "Cannot GET /home" and nothing in the console

I'm new in angularJs someone can explain to me my issue ?

9
  • where is the controller? Commented Feb 29, 2016 at 13:33
  • i re-edit with the controller :) Commented Feb 29, 2016 at 13:35
  • What is it in your html template, that you expect to show in <ion-nav-view></ion-nav-view> Commented Feb 29, 2016 at 13:45
  • I expect to see my h1 tag not a white page Commented Feb 29, 2016 at 13:47
  • Put an alert inside the homeCtrl, see if that is being hit. I can't seen anywhere in the view you are using the "homeCtrl" Commented Feb 29, 2016 at 13:49

3 Answers 3

2

You should be going to #/home:

http://localhost:8100/#/home 
Sign up to request clarification or add additional context in comments.

1 Comment

same white page even with this url
0

Try the following url and sure your controller is loading:

http://localhost:8100/#/app/home 

Comments

0

Please double check your app.routing.module.ts, there might be a problem on path declaration.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.