Input[number] with ng-model and placeholder


#1

Hi there,

I got a problem with the ionic framework (which works when I use plain angularjs: http://jsfiddle.net/StT2y/2/)

Wanted Behavior:

  • Input field with type number & placeholder
  • Bound to model via ng-model
  • Placeholder is displayed before user edits the input
  • Once the user makes an input it should bind to the model

Current code:

<input type="number" min="0" placeholder="7500" ng-model="totalClicks" required>
<button ng-click="clicks()">Click</button> 

angular.module('ExampleApp',[]);
angular.module('ExampleApp')
.controller('ExCtrl',function($scope){
    $scope.totalClicks = '';         
    $scope.clicks= function(){
        alert($scope.totalClicks);
    };
});

Current behavior:

The alert gives me undefined.


#2

Never mind it’s my mistake.
However, if I initialize

$scope.funnel = {totalClicks: ''}

and change it to

<input type="number" min="0" placeholder="7500" ng-model="funnel.totalClicks" required>

it doesnt work


#3

Yes, you need to be sure to always use “dot notation”.