Selected value is not clearing with ng-if.

2 posts, 1 answers
  1. developer
    developer avatar
    58 posts
    Member since:
    Nov 2015

    Posted 27 Jul 2016 Link to this post

    I'm having a functionality to load the DOM elements on demand. for that, I'm using ng-if the selected value is not clearing. Find the below example to reproduce the scenario.


    In this example, first control is with with "ng-if" and 2nd example with "ng-show". "ng-show" is working. But "ng-if" is not working. 

    Please assist to fix the issue.

  2. Answer
    Georgi Krustev
    Georgi Krustev avatar
    3725 posts

    Posted 29 Jul 2016 Link to this post


    It seems that the specifics of ngIf directive, the first datepicker binds to a different $scope.dateFromObject instance, which prevents any subsequent model field modifications. The possible solutions in this case are:
    • use only ngShow directive, as it will keep the HTML rendered on the page
    • use "Ctrl as vm" to overcome the ngIf behavior -

    Georgi Krustev
    Telerik by Progress
    Get started with Kendo UI in days. Online training courses help you quickly implement components into your apps.
Back to Top