Wallcraft Wallcraft - 1 year ago 70
AngularJS Question

I dont understand why my code wont works

Hi all i'm approaching to AngularJS, it seemed to be easy, but i understood that it isn't.
I want to do a simple login without authentication, just a login that you insert username and passowrd, click on the login button and a message appears and notify you that you have logged in.
I gave a look at the documentation and i write this code

<!DOCTYPE html>
<title>Login Prova</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>
<div ng-app="mainApp" ng-controller="AppController">
Inserisci username<input type="text" ng-model="username1">
Inserisci password<input type="password" ng-model="password">
<button ng-click="stampa()">Click!</button>
<p>Ciao {{result}}</p>
var mainApp = angular.model("mainApp",[]);
mainApp.controller('AppController',['$scope', function($scope){
$scope.result = null;
$scope.stampa = function(){
$scope.result = "Logged in";

Thanks you all for the possibile solution.

Answer Source

You have a typo. There is no angular.model function. You meant to put angular.module.

var mainApp = angular.module("mainApp",[]);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download