Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • How to make my angular js function to run only one time?

    • 0
    • 0
    • 0
    • 2
    • 0
    • 0
    • 0
    • 633
    Answer it

    I have this plunker.How to make that function to be executed only one time ?

    The code is:

    <!DOCTYPE html>
        <script data-require="angular.js@1.1.5" data-semver="1.1.5" src=""></script>
        <link rel="stylesheet" href="style.css" />
        <script src="script.js"></script>
      <body ng-app>
        <div ng-controller="testCtrl">
            <h3>Why does scope function executes X times</h3>
            <div>getLabel executed {{counter}} times</div>
            <div>getLabel result {{getLabel('test')}}</div>
            <div ng-bind="myModel.tmp"></div>
            <div ng-bind="myModel.tmp2"></div>



    Why does scope function executes X times

    getLabel executed 10 times

    getLabel result My label

    Temp value

    Temp value 2


    I have executed the code here:

 2 Answer(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: