1

angularjs ng-init alternative in angular 2 or 4.

i written sample code of angularjs in below it working correctly but i want to same logic in angular 2 or 4.

calling the method via html if the condition is true.

sample.controller.js

$scope.showDiv = true;

$scope.callFunction = function() {
        console.log("myFunction");
};

sample.html

<div ng-if="showDiv">
    <div ng-init="callFunction()"></div>
</div>
Chandru
  • 10,864
  • 6
  • 38
  • 53

0 Answers0