Search code examples
javascripthtmlangularjsionic-v1

how to make ng-change work to change sentence 1 to sentence 2


thanks for the help. Sentence1: hello this is java , on click of it it should change to Sentence2: Hello this is not java.

can anyone give me a good solution for this , I have a input tag and check box and there ng-change is working fine , but I want the same logic with text change.

<div ng-model="form.app" ng-change="updating()" >  
<input ng-model="form.app" ng-change="updating()" type="checkbox">

Solution

  • I need to change the text from yes to no on click.

    Use AngularJS expressions:

    <script src="//unpkg.com/angular/angular.js"></script>
    <body ng-app>
        <input ng-model="form.app" type="checkbox">{{form.app}}
        <div>Hello, this is {{!form.app?'not':''}} Java</div>
    </body>

    For more information, see AngularJS Developer Guide - Interpplation and data-binding.