I have a problem with the angular, I have a more than button with value 1 - 9, I would if I click the button 1. value of input type="text" automatic be 1..
this example code :
<input type="text" class="tags" ng-model="data.tes">
<br>
<button value="1" class="phoneNumber" ng-model="data.tes">1</button>
any suggestion for me?
Thanks in advance.
The ng-model directive can also be applied to the input elements such as the text box, checkboxes, radio buttons, etc. Let's look at an example of how we can use the ng-model with the “textbox” and “checkbox” input type.
Ans1: The execution context is another key difference between ng-click and onclick. An expression inside of ng-click runs against a specific scope object, often the scope object representing the model for the current controller, whereas code inside an onclick attribute executes against the global window object.
For a single btn, it's ok to use ng-click or onclick in the ng-app . There is no difference between the two functions. For effective team work, you,d better to have an account with each other. In Angular apps, ng-click is recommended.
The ng-click Directive in AngluarJS is used to apply custom behavior when an element is clicked. It can be used to show/hide some element or it can pop up an alert when the button is clicked.
<button class="phoneNumber" ng-click="data.tes = 1">1</button>
For more than 1 button
in your controller
$scope.buttons = [1,2,3,4,5,6,7,8,9]
and in your markup
<button ng-repeat="button in buttons" ng-click="data.tes = button">{{button}}</button>
EDIT
You may want to declare your object in the controller as well
$scope.data = {};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With