Reputation: 135
I'd like to load a template html in my main index.html when I view my angular project but I always get an empty screen.
<!DOCTYPE html>
<html lang="nl" ng-app="store">
<head>
<meta charset="UTF-8">
<title>NMDAD-II Web App</title>
<link rel="stylesheet" href="css/main.css">
<link rel="stylesheet" href="css/style.css">
</head>
<body class="bg-darkRed" ng-controller="StoreController as store">
<div ng-view></div>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28//angular-route.min.js"></script>
<script src="vendor/angular/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="js/main.js"></script>
<script src="app/app.js"></script>
<script type="text/javascript">
angular.module("store", ["ngRoute"])
.config(function($routeProvider){
$routeProvider
.when('/', {
templateUrl: 'app/home/home.view.html'
})
.otherwise({
redirectTo: '/'
});
});
</script>
<script id="__bs_script__">//<![CDATA[
document.write("<script async src='http://HOST:3000/browser-sync/browser-sync-client.2.11.2.js'><\/script>".replace("HOST", location.hostname));
//]]></script>
</body>
</html>
I've also tried to load it with browser sync but it's still the same. I want to load home.view.html in my index.html. I tried to write the javascript in app.js but that still didn't work.
EDIT: this is my app.js. my main.js just contains some jquery
function () {
'use strict';
// Module declarations
angular.module('store', [
// Angular Module Dependencies
// ---------------------------
'ngAnimate',
'ngMaterial',
'ngMessages',
'ngResource',
// Third-party Module Dependencies
// -------------------------------
'ui.router', // Angular UI Router: https://github.com/angular-ui/ui-router/wiki
// Custom Module Dependencies
// --------------------------
'store.home',
'store.services'
]);
angular.module('store.home', []);
angular.module('store.services', []);
// Make wrapper services and remove globals for Third-party Libraries
angular.module('store')
.run(Run);
function Run(
$_,
$faker
) {}
var app = angular.module('store',[]);
app.controller('StoreController', function(){
this.products = gems;
});
var gems = [
{
title: "Islay Blended Malt",
description: "The Isle of Islay is known for its peaty whiskies. For there is a great abundance of peat on the island, and because electricity reached Islay so late, peated was relied upon as a staple source of fuel. But there is so much than just peat to be found.",
price: "103.45",
canPurchase: true
},
{
title: "Springbank 10 Year old",
description: "Blended from a mixture of bourbon and sherry casks, the light colour of this malt belies the richness of its character.",
price: "36.25",
canPurchase: true
},
{
title: "Hazelburn 10 Year old",
description: "First released in 2014, this is the first bottling of Hazelburn at 10 years of age. Hazelburn is Springbank's triple-distilled, unpeated single malt.",
price: "37.75",
canPurchase: true
}
]
})();
Upvotes: 1
Views: 120
Reputation: 2559
The problem I see is you are loading angular-route before you load angular.
Try switching those two lines to:
<script src="vendor/angular/angular.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.28//angular-route.min.js"></script>
I get this error ReferenceError: angular is not defined
when I load the scripts how you are loading them.
Upvotes: 1