Dismiss
Announcing Stack Overflow Documentation

We started with Q&A. Technical documentation is next, and we need your help.

Whether you're a beginner or an experienced developer, you can contribute.

Sign up and start helping → Learn more about Documentation →

I am rendering a view dynamically. eg :

username          --> type : text input
password          --> type : text password
company           --> type : text : input
keep me logged in --> type : boolean checkbox

Each text-box, radio-button, checkbox and any input-element render from directive that have isolated scope.

Now there is a button called Sign In on click of the button there is some rule that tell me read all value and call api.

The challenge is when I click on button SIGN IN how can I read value of username, password, company and keep me logged in check box. Because I don't have scope variable set. I don't even know how many input-elements are there.

Any help would be a great supprt

share|improve this question

index.html

<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>  
<body>

<h2>Angular js get input Example</h2>

<form ng-app="demoApp" ng-controller="validationCtrl" 
name="myForm">
<p>Username:<br><input type="text" name="user" ng-model="user.name" ></p>
<p>Email:<br><input type="email" name="email" ng-model="user.email" ></p>
<p>password:<br><input type="password" name="email" ng-model="user.pass" ></p>
<p>check:<br><input type="checkbox" name="email" ng-model="user.check" ></p>
<input type="submit" ng-click="alldata(user)"></p>
</form>
<script>
//This is controller
var app = angular.module('demoApp', []);
app.controller('validationCtrl', function($scope) {
   $scope.alldata=function(user)
   {
    alert(JSON.stringify(user));
   }
});
</script>
</body>
</html>
share|improve this answer
    
Thanks for reply . but how do you know the scope ? I said each inputs have isolated scope in directive. – Naushad Ahmad Jun 22 at 7:25

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.