title: call a function in angularjs controller from html and scope variable is not defined
body: <p>I am a newbie in angularjs and need to know how to call a function which is define in controller from html in angularjs</p>
  
  <p>I have wrote a code html</p>
  
  <pre><code> First.html
  
  &lt;input type="text" ng-model="model.name" name="name" /&gt;
  
   Second.html
  
  &lt;p g-bind-template&gt;{{model.familyname}}&lt;/p&gt; // it displays the value
  &lt;div data-ng-controller="formCtrl" data-ng-init="init()"&gt;
        &lt;/div&gt;
  </code></pre>
  
  <p>Is this way is correct or is there any other way to call a function. Also when init() is called scope variable is undefined</p>
  
  <pre><code>$scope.init = function () {
        alert($scope.model.name); // it displays undefined
  
      };
  </code></pre>
  
  <p>Any help is very much appreciated</p>