John Doe
John Doe

Reputation: 49

How to make a small angular app in Chrome?

I am trying to make a Chrome app (not an extension, but a desktop app). I have the window.html file as follows:

<!DOCTYPE html>
<html ng-app="app">
<head>
    <title>This is a test</title>
    <script src="js/angular/angular.min.js"></script>
    <script src="js/modules/login.js"></script>
</head>
<body>
<section ng-controller="LoginController as login">
    <div>{{3 + 4}}</div>
</section>
</body>
</html>

and my login.js file is:

var app = angular.module('LoginController', []);

However, when I run the app, it shows {{3 + 4}}, not 7.

My manifest file is:

{
  "name": "APP",
  "description": "My App",
  "version": "0.1",
  "manifest_version": 2,
  "app": {
    "background": {
      "scripts": ["background.js", "js/angular/angular.min.js"]
    }
  },
  "icons": { "16": "app.jpg", "128": "app-128.jpg" }
}

What am I doing wrong?

Upvotes: 1

Views: 84

Answers (2)

devqon
devqon

Reputation: 13997

You have the ng-app="app", but your app is called "LoginController". Do it like the following:

var app = angular.module('app', []); // first parameter is the name that can be used in ng-app=

// create the controller with its name
app.controller("LoginController", function(){});

Upvotes: 2

Gnanadurai Asudoss
Gnanadurai Asudoss

Reputation: 279

Change this to

var app = angular.module('LoginController', []);

this

var app = angular.module('app', []);
app.controller("LoginController",function(){
});

Upvotes: 0

Related Questions