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 pursuing MBA 1st Year. I want to learn Digital Marketing. Is it right for career growth, or should I choose to learn some other technologies? If yes, please give me your suggestions that help me to get a JOB in the IT Sector.
Hi Sai, To find right career path you need to try things ( Which is long way). I would suggest you to learn multiple things ( implementation is important part) and then find your intrest and dive in to...
Sai
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

As web designer what is easy and useful to learn Angular or React?

If you are having prior Javascript knowledge then React is easy than Angular.
Nikunj

Which is Easy Angular or React JS ?

Both are tough(or easy) in their own way. React learning curve is short(not easy) but implementation is tougher than Angular. Angular learning curve is lengthy but implementation is easier than React
Ganesh
What is routing in angularjs?
If you want to navigate to different pages in your application, but you also want the application to be a SPA (Single Page Application), with no page reloading, you can use the switching Route module. The...
Srikanth
0 0
9

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

Ask a Question

Related Lessons

Angular Routing Overview
a. Routes: The browser is a familiar model of application navigation: Enter a URL in the address bar and the browser navigates to a corresponding page. Click links on the page and the browser...

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...

EFFECTIVE TASKS & RESPONSIBILITIES DELEGATION
Do you feel your business relies too much on you? In working with business owners, there are a couple of tools we introduce to productively shift the workload and responsibility across the organization....

Some good resources
Clean Code by Robert C Martin, is available in my profile please download and read it, irrespective of what language you code in, it will change the way you code. Also if you code in Javascript read https://12factor.net/ https://blog.risingstack.com/javascript-clean-coding-best-practices-node-js-at-scale/ For...

Dependency Injection in Angular 2
Dependency injection Dependency injection is a way to supply a new instance of a class with the fully-formed dependencies it requires. Most dependencies are services. Angular uses dependency injection...

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