Alex McCalman Alex McCalman - 4 months ago 27
Javascript Question

Including AngularJS modules in HTML

I've recently been trying to learn AngularJS, but I can't seem to get my HTML to see the angular module I've made. The bindings seem to work if they don't interact with the module...


<!DOCTYPE html>
<html ng-app="productsModule">
<meta charset="UTF-8">

<script src="../lib/dependencies/angular.min.js"></script>
<script src="../lib/dependencies/angular-resource.min.js"></script>

<script src="../scripts/products.module.js"></script>

<div ng-contoller="ProductListJSController as productList">
<h1>Product Test Page</h1>

<span>Total number of products: {{ }}</span>

<span>{{ productList.test }}</span>

<th>Price (£)</th>
<tr ng-repeat="product in productList.products">

<p> 1 + 2 = {{1+2}} </p>


My JS:

angular.module('productsModule', [])
.controller('ProductListJSController', function(){
//var productList = this;

this.test = 'test';

this.products = [
{id: 53, name:'gnome 1', price: 50},
{id: 54, name:'gnome 2', price: 70},
{id: 55, name:'gnome 3', price: 90}]; = function(){
var count = 0;
angular.forEach(this.products, function(){
count += 1;
return count;

I'm pretty sure I've done everything right, and it's mostly the same as the examples I've found, but it just doesn't seem to display any of the bindings refering to the product module.


Check your spelling:

<div ng-contoller="ProductListJSController as productList">

Should be:

<div ng-controller="ProductListJSController as productList">