Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular controller not working

I'm newbie to angular My angular controller is:

var chatApp = angular.module('chatApp.controllers', []);

chatApp.controller('loginController', ['$scope', function($scope) {
$scope.user_name="name";
$scope.user_password="name";
}]);

the app.js is:

'use strict';
angular.module('chatApp', [
'ui.router',
'chatApp.filters',
'chatApp.services',
'chatApp.directives',
'chatApp.controllers'
]).config(function($stateProvider, $urlRouterProvider) {
$stateProvider
    .state('login', {
        url: "/login",
        templateUrl: "partials/login.html",
        controller : "loginController"
    })
});

login.html is:

<div>
<div id="wrapper">
    <form name="login-form" class="login-form" action="" method="post">
        <div class="header">
            <h1>Login Form</h1>
        </div>
        <div class="content">
            <input name="username" type="text" class="input username" placeholder="{{user_name}}" />
            <div class="user-icon"></div>
            <input name="password" type="password" class="input password" placeholder="{{user_password}}" />
            <div class="pass-icon"></div>
        </div>
    </form>
</div>

I've used stateprovider for routing. But, it's not showing anything in placeholder. What is the reason?

like image 687
pnv Avatar asked Nov 26 '22 08:11

pnv


1 Answers

Solved the problem using ng-model instead of {{}}.

<div class="content">
            <input name="username" type="text" class="input username" placeholder="username" ng-model="user_name" />
            <div class="user-icon"></div>
            <input name="password" type="password" class="input password" placeholder="password" ng-model="user_password"/>
            <div class="pass-icon"></div>
        </div>
like image 95
pnv Avatar answered Feb 09 '23 00:02

pnv