Solved

Two TextBox and a Button AngularjS

Posted on 2014-09-19
2
1,804 Views
Last Modified: 2014-09-19
I have two textboxes one is Snumber and another dNumber and one FIND button. What I want is if I am entering sNumber, then button click goes to a page and if I enter dNumber then button click go to another page. How can this be done in AngularJS?

             
                 <div class="form-group">
                                 <label class="control-label">S Number</label>
                                 <div class="form-group">
                                    <input type="text" class="form-control"  data-ng-model="sNumber" >
                                 </div>
                              </div>
                              <div class="form-group">
                                 <label class="control-label">D Number</label>
                                 <div class="orm form-group">
                                    <input type="text" class="form-control" data-ng-model="dNumber" data-ng-maxlength=20 data-ng-minlength=5  required>
                                 </div>
                              </div>
                           </div>
                        </form>
                        <div class="form-actions">
                           <a data-ng-href="#/sDetailsList/{{sNumber}}" class="btn btn-lg green" >Find Data(s)</a>
			   <a data-ng-href="#/dDeatilsList/{{dNumber}}" class="btn btn-lg green" >Find Data(s)</a>
			</div>

Open in new window

0
Comment
Question by:rbhargaw
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40333660
hope that help : http://jsfiddle.net/2m3o6tsc/

Using : ng-hide="!dNumber||sNumber.length" and ng-hide="!sNumber||dNumber.length"

<div ng-app="myApp" ng-controller="myCtrl">
    <form>
        <div>
            <div class="form-group">
                <label class="control-label">S Number</label>
                    <div class="form-group">
                        <input type="text" class="form-control"  data-ng-model="sNumber" ng-disabled="dNumber.length" />
                    </div>
            </div>
            <div class="form-group">
                <label class="control-label">D Number</label>
                <div class="orm form-group">
                    <input type="text" class="form-control" data-ng-model="dNumber" data-ng-maxlength=20 data-ng-minlength=5 ng-disabled="sNumber.length"  required />
                </div>
            </div>
        </div>
    </form>
    <div class="form-actions">
        <a data-ng-href="#/sDetailsList/{{sNumber}}" class="btn btn-lg green" ng-hide="!sNumber||dNumber.length" >Find Data(s)</a>
        <a data-ng-href="#/dDeatilsList/{{dNumber}}" class="btn btn-lg green" ng-hide="!dNumber||sNumber.length" >Find Data(s)</a>
    </div>
</div>

Open in new window

0
 

Author Comment

by:rbhargaw
ID: 40333713
That's exactly what I needed! Thanks!
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction A frequently asked question goes something like this:  "I am running a long process in the background and I want to alert my client when the process finishes.  How can I send a message to the browser?"  Unfortunately, the short answer …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question