当前位置: 动力学知识库 > 问答 > 编程问答 >

angularjs - 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>

<html>

<head>

<title>Login Prova</title>

<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.8/angular.min.js"></script>

</head>

<body>

<h1>Login</h1>

<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>

</div>

<script>

var mainApp = angular.model("mainApp",[]);

mainApp.controller('AppController',['$scope', function($scope){

$scope.result = null;

$scope.stampa = function(){

$scope.result = "Logged in";

}

}]);

</script>

</body>

</html>

Thanks you all for the possibile solution.

网友答案:

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

var mainApp = angular.module("mainApp",[]);
分享给朋友:
您可能感兴趣的文章:
随机阅读: