How Do I call the function with ng-model in AngularJs?

Asked by Last Modified  

Follow 0
Answer

Please enter your answer

Senior Programmer

It's not possible to pass a function to ng-model because Angular has to be able to set the value when the user changes the input value. You cannot tell Angular to instead call a function when the value is changed. But I'd say that you're better of creating a $watch for the property as that will be...
read more
It's not possible to pass a function to ng-model because Angular has to be able to set the value when the user changes the input value. You cannot tell Angular to instead call a function when the value is changed. But I'd say that you're better of creating a $watch for the property as that will be more familiar to other Angular devs. var model1 = { value: 'hi' }; var model2 = { value: 'hello' }; $scope.model = model1; $scope.checkboxValue = true; $scope.$watch('checkboxValue', function(value) { if (value) { $scope.model = model1; } else { $scope.model = model2; } }); here you can use ng-model="checkboxValue" Thanks read less
Comments

Related Questions

Hi, I am working as a web designer and want to work as UI developer. So what should I have to learn initially? And learning Angular Js would be a good option?
It is good choice web designer to become web developer (UI developer). Start with the basics first learn HTML and CSS, Then go and continue with bootstrap and Angular js.
Mudita
How to create sliding tabs in ionic ?
We can create sliding tabs using ion-tab in ionic.
Gowravaram
0 0
5
Hi, can you explain about Angular JS training and project explanation on it?
If you like I could give you sessions on Angular Js and guide you on the same to build client side applications.
Kiranteja
How Nodejs and Angular Work together?
If you need to connect Angular js With node js . you should use express js as middle ware.
Raminder
Where should we implement the DOM Manipulation in Angularjs ?
To manipulate the DOM we have directives in Angular JS like ng-show, ng-hide etc. Basically a directive is used to generate the dynamic content i.e., HTML at run time.
S.V.R
0 0
6

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Mark And Sweep Algorithm in Javascript Memory Management
This algorithm reduces the definition of "an object is not needed anymore" to "an object is unreachable". This algorithm assumes the knowledge of a set of objects called roots (In JavaScript, the root...

Angular Material
What is Angular Material? For developers using AngularJS, Angular Material is both a UI Component framework and a reference implementation of Google's Material Design Specification. This project provides...

AngularJS Routes
Q. How to set up Angular JS Routes? Ans: Set up the application in below format: AngularJS(Folder)/ ---index.html ---home.html ---about.html ---css/style.css ---js/angular.js ---js/angular--routes.js ---js/app.js i....

Introduction to Angular JS
What is AngularJS? AngularJS is a structural framework for dynamic web apps. It lets you use HTML as your template language and lets you extend HTML's syntax to express your application's components clearly...

Inversion of Control
Problem You have classes that have dependencies on services or components whose concrete type is specified at design time. In this example, ClassA has dependencies on ServiceA and ServiceB. Figure 1 illustrates...

Recommended Articles

Microsoft Excel is an electronic spreadsheet tool which is commonly used for financial and statistical data processing. It has been developed by Microsoft and forms a major component of the widely used Microsoft Office. From individual users to the top IT companies, Excel is used worldwide. Excel is one of the most important...

Read full article >

Information technology consultancy or Information technology consulting is a specialized field in which one can set their focus on providing advisory services to business firms on finding ways to use innovations in information technology to further their business and meet the objectives of the business. Not only does...

Read full article >

Whether it was the Internet Era of 90s or the Big Data Era of today, Information Technology (IT) has given birth to several lucrative career options for many. Though there will not be a “significant" increase in demand for IT professionals in 2014 as compared to 2013, a “steady” demand for IT professionals is rest assured...

Read full article >

Almost all of us, inside the pocket, bag or on the table have a mobile phone, out of which 90% of us have a smartphone. The technology is advancing rapidly. When it comes to mobile phones, people today want much more than just making phone calls and playing games on the go. People now want instant access to all their business...

Read full article >

Looking for Angular.JS Training?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you