javascript - $scope element becomes "undefined" after being changed -


i have controller , object

app.controller('maincontroller', function( $scope, $rootscope, $window, $state, $urlrouter, $http, content, flash, $modal, $stateparams ) {      $scope.user = {         username: '',         password: '',         email: 'default-value'     }      $scope.log = function ( message ) {         console.log( message )     }  ... 

and html this:

<form class="form-inline form-waitlist" ng-show="showsignup">     <span class="form-group">         <input type="email" class="input-white form-control input-font-lg" ng-model="user.email" placeholder="email" />          <button class="btn btn-white btn-lg hidden-xs" ng-click="log( user.email )">sign {{ user.email }}</button> ... 

when load page field default-value, in object in controller. change typing in field, turns undefined. i'm in view, landing.splash, configured this:

$stateprovider     .state( 'landing', {         url: '/home',         templateurl: 'app/views/landing.html',         controller: 'maincontroller'     })         .state( 'landing.splash', {             url: '/splash',             templateurl: 'app/views/landing-splash.html'         }) 

any thoughts on how diagnose problem?

because input type email. when enter invalid email string, angularjs not assign value $scope.

please check working demo: http://jsfiddle.net/jl3sa5e9/2/. if enter invalid email, {{ user.email }} not output anything. after input valid email joy@xiamen.com, displayed.

javascript:

angular.module('joy', []) .controller('myctrl', ['$scope', function ($scope) {     $scope.user = {         email: ''     }; }]); 

html:

<div ng-app="joy">     <div ng-controller="myctrl">         <input ng-model="user.email" type="email">         <div>email: {{ user.email }}</div>     </div> </div> 

Comments

Popular posts from this blog

javascript - Karma not able to start PhantomJS on Windows - Error: spawn UNKNOWN -

c# - Display ASPX Popup control in RowDeleteing Event (ASPX Gridview) -

Nuget pack csproj using nuspec -