1

Im new to angularjs so its hard for me to figure this thing out. Im getting error of [$compile:tpload]. What could be a problem here? HTML:

<body ng-app="App">
<div ng-view>
    ...
</div>
<a href="#main">Access</a>

JS:

var App = angular.module('App', ["ngRoute"]);
App.config (function ($routeProvider){
 $routeProvider
 .when("/main", {
     templateUrl : "yup.html"
 })
});

yup.HTML:

<p>...</p>

What im doing wrong?

Vanagasa
  • 13
  • 5
  • did you downloaded and included the `angular-route.js` file? – Dan Costinel Jan 16 '17 at 19:42
  • The `templateUrl` is a relative path from the file you declare the routing. The error is indicating that it cannot load the template so make sure your pointing to the html file correctly. – Ben Felda Jan 16 '17 at 19:45
  • It is in the same folder as other ones, so it should point correctly and yes I included it – Vanagasa Jan 16 '17 at 20:10

1 Answers1

0

Looks like there is no issue with your code, except that the angular-route.js file is not loading. Change the source link from http to https to get it working. Browser is blocking the url as script through http is insecure. Updated Plunkr

Community
  • 1
  • 1
Supradeep
  • 3,246
  • 1
  • 14
  • 28
  • It is in the same location – Vanagasa Jan 16 '17 at 20:15
  • Can you template as I've done above and check if it's working ? – Supradeep Jan 17 '17 at 03:09
  • Now it doesnt show any errors and there is and empty space for it but it doesnt show up when i added: – Vanagasa Jan 17 '17 at 13:44
  • You might've missed adding content in it. Can you check that once. – Supradeep Jan 17 '17 at 13:47
  • You mean add

    Content of the template.

    ? If so then it only shows Content of the template.
    – Vanagasa Jan 17 '17 at 14:16
  • Yeah. That is the purpose of your routing right? What is your requirement exactly? Can you create a plunkr and share? – Supradeep Jan 17 '17 at 14:19
  • https://plnkr.co/edit/37ayj0bCdOvdgivWKZiy?p=preview I mean the problem is that I need to write what i need betwean the lines of script that way when i need to get it from yup.html – Vanagasa Jan 17 '17 at 14:40
  • @Vanagasa: I've updated your plunkr, removed the `ng-template`, there was an error loading angular-route, fixed it. https://plnkr.co/edit/1g32hz7GPOujbjWr5Dwp?p=preview. Check and let me know if that is working as expected. – Supradeep Jan 17 '17 at 15:28
  • It works as expected, but somehow if i copy all this to my code it doesnt work and i would like to know how you fixed it – Vanagasa Jan 17 '17 at 15:51
  • The issue in the plunkr was that `angular-route` file was not loading, I've changed the source url to `https` from `http` – Supradeep Jan 17 '17 at 15:53
  • No problem. Happy to help :) – Supradeep Jan 17 '17 at 16:02