Solucionado (ver solução)
Solucionado
(ver solução)
4
respostas

Versão Do angular? - StateRoutes

Boa tarde

Troquei os meus fontes pelos fornecidos ao final da aula pra ver se voltava a funcionar... mas nada.

Depois da parte do routes passei a receber esse erro

"Error: [ng:areq] Argument 'ListagemController' is not a function, got undefined http://errors.angularjs.org/1.5.3/ng/areq?p0=ListagemController&p1=not%20a%20function%2C%20got%20undefined

Obrigado

// 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'
angular.module('starter', ['ionic'])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    if(window.cordova && window.cordova.plugins.Keyboard) {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);

      // Don't remove this line unless you know what you are doing. It stops the viewport
      // from snapping when text inputs are focused. Ionic handles this internally for
      // a much nicer keyboard experience.
      cordova.plugins.Keyboard.disableScroll(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})
-----------------------------
angular.module('starter')
.controller('ListagemController', function($scope){

    $scope.listaDeCarros =  ["BMW 120i", "Onix 1.6", "Fiesta 2.0", "C3 1.0", "Uno Fire", "Sentra 2.0",
                                "Astra Sedan", "Vectra 2.0 Turbo", "Hilux 4x4", "Montana Cabine dupla",
                                "Outlander 2.4", "Fusca 1500"];

});

angular.module('starter').controller('CarroEscolhidoController', function($scope, $stateParams) {

    $scope.carroEscolhido = $stateParams.carro;

});
-----------------------------
angular.module('starter')
.config(function($stateProvider, $urlRouterProvider) {

  $urlRouterProvider.otherwise('/listagem');

  $stateProvider

  .state('listagem', {
    url: '/listagem',
    templateUrl: 'templates/listagem.html',
    controller: 'ListagemController'
  })

  .state('carroescolhido', {
    url: '/carroescolhido/:carro',
    templateUrl: 'templates/carroescolhido.html',
    controller: 'CarroEscolhidoController'
  })
});
-----------------------------

<!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 rel="manifest" href="manifest.json">

    <!-- un-comment this code to enable service worker
    <script>
      if ('serviceWorker' in navigator) {
        navigator.serviceWorker.register('service-worker.js')
          .then(() => console.log('service worker installed'))
          .catch(err => console.log('Error', err));
      }
    </script>-->

    <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>

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

    <!-- your app's js -->
    <script src="js/app.js"></script>
    <script src="js/controller.js"></script>
  <script src="js/routes.js"></script>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0rc1/angular-route.min.js"></script>

</head>

<body ng-app="starter" ng-controller="ListagemController">

    <ion-pane>
        <ion-header-bar class="bar-stable">
            <h1 class="title">Alura Car</h1>
        </ion-header-bar>





        <ion-footer-bar class="bar-stable">
            <h1 class="title" >Rua Padre Agostinho {{cep}}</h1>
        </ion-footer-bar>

    </ion-pane>

</body>

</html>
----------------------------
4 respostas

Olá.

Tenta tirar esse ng-controller="ListagemController" do seu index. Eu tentei achar o erro no restante do código mas nao achei. Vamos tentar tirar isso e achar uma solução pra vc

Boa tarde,

Obrigado

Então, se eu retiro fica ok.

solução!

Bom...aparentemente eu tava afzendo o import do controlers.js errado. Comecei a usar o visual estudio e não me liguei que ao passar o mouse em cima do import ele fica grifado(como se o caminho estivesse certo mesmo que não esteja...). Apenas após o clique ele mostra se achou ou não.

Obrigado pela ajuda

Abs

Que bom que resolveu.

Espero que esteja gostando do curso.

Grande abraço