Dennis Mennis
Dennis Mennis

Reputation: 11

Angularjs not working without localhost

I am new to angularjs.I started an angular application with the help of yeoman generator. I was able to run the app in localhost but not able to run without any server.My application doesnt required any server.Please see my code below.

<script src="bower_components/jquery/dist/jquery.js"></script>
            <script src="bower_components/angular/angular.js"></script>
            <!-- <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script> -->
            <script src="bower_components/angular-animate/angular-animate.js"></script>
            <script src="bower_components/angular-cookies/angular-cookies.js"></script>
            <script src="bower_components/angular-resource/angular-resource.js"></script>
            <script src="bower_components/angular-route/angular-route.js"></script>
            <script src="bower_components/angular-sanitize/angular-sanitize.js"></script>
            <script src="bower_components/angular-touch/angular-touch.js"></script>
            <script src="bower_components/angular-aria/angular-aria.js"></script>
            <script src="bower_components/angular-material/angular-material.js"></script>
            <script src="bower_components/angular-ui-router/release/angular-ui-router.js"></script>
            <script type="text/javascript" src="scripts/app.module.js"></script>
            <script type="text/javascript" src="scripts/controllers/wizard.js"></script>

        </head>
        <body ng-app="myApp">
            <div ui-view></div>
        </body>

Below is the main app module:

angular
  .module('myApp', [
    'ngSanitize',
    'ngCookies',
    'ngResource',
    'ui.router',
    'ngMaterial'
  ])
  .run(function () {
      alert("Run Block");

  })
.config(function ($urlRouterProvider,$stateProvider) {
  $urlRouterProvider.otherwise('/wizard');
    $stateProvider
    .state('wizard', {
      url: '/wizard',
      templateUrl: 'views/wizard.html',
      controller: 'WizardController',
      controllerAs: 'vm'
    })
    .state('wizard.layer', {
      url: '/layer',
      templateUrl: 'views/layer.html',
      controller: 'LayerController',
      controllerAs: 'vm'
    });
  });

In my views folder above mentioned two html files are there. But i am not able to run files without server.Its working with grunt serve. Even my run block in angularjs not get fired when i openeed index.html in firefox. I dont know why it is happening.Can anyone help me out of this problem. Any help will be appreciated.

Thanks.

Upvotes: 1

Views: 783

Answers (1)

Nikhil Sharma
Nikhil Sharma

Reputation: 941

You are using urlRouterProvider which makes ajax requests to render the html files. These requests will fail because there is no server running to serve the request.

Upvotes: 1

Related Questions