0

I'm having two HTML files -> index.html and start.html

So far I was developing an app(a small application) in a single dimensional thought where index.html serves as the main page and app-route serves as the main router for the application. Now we're creating a bigger application like a .com site and integrating the previous application with the this(.com).

We do not want to disturb the smaller application code and we're developing a .com site which is a different html(start.html) and a different router (dot-com-route.js). Now, whenever I try to load http://localhost/myApp/app/#/start.html, its loading the index.html with app-route.js?

Is it always like, angular application looks for index.html file to execute?

This is my app-route.js:

smartPrintApp.config(['$routeProvider','$locationProvider',
  function($routeProvider, $locationProvider) {
      $routeProvider.
      when('/', {
        templateUrl: 'pages/smart_print_landing/smart-print-landing.html'
      }).
      when('/index.html', {
        templateUrl: 'pages/smart_print_landing/smart-print-landing.html'
      })
  }
]);
3
  • I believe you have put in you angular code that on route (when('/')) it uses index.html. Can you post your JS code? Commented May 13, 2015 at 9:36
  • @vucko I've updated the app-route.js for you Commented May 13, 2015 at 9:42
  • 1
    When you hit your localhost/myApp/app/#/start.html browser will load some HTML(depends on your backend) this should be your index.html then angular will check the hash and will load a template you specified in templateUrl and it will inject it into index.html wherever you have ng-view attribute. If you want start.html to be served instead of index.html then you need to change this on server. Sorry if i didn't understand what you want exactly Commented May 13, 2015 at 10:10

1 Answer 1

2

When you're attempting to open http://localhost/myApp/app/#/start.html the part of the URL that the server will actually try to serve is http://localhost/myApp/app/. After the server has sent the browser the requested page AngularJS will come into play and read the part after the has (#) to determine which route to use. Since you have not included a specific HTML file in the part that the server is reading the server will serve the HTML file that has been set as the default (I assume from the behaviour you are getting that this is index.html).

So in order to get your second landing page you should use http://localhost/myApp/app/start.html/#/ (or something similar depending on the route you wish to access) as the URL.

Sign up to request clarification or add additional context in comments.

1 Comment

The url that worked for me was -> localhost/dotcom/app/start.html# Previously I was trying localhost/dotcom/app/#/start.html which is wrong.

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.