angular-php-ng-view-issue

I am having a problem calling a function from a template file loaded via the ng-view directive. If I call the same function inside of the "shell" aka main page that load the ng view, the function call works fine. If I call it from within a template that is loaded with ng-view it does not work

by Billy Figueroa

HTML

<php?
    require_once 'Greet.php';
    $greet = new Greet();
?>

    <body ng-app="testApp">
        <?php $greet->sayHello(); ?>
        <div data-ng-view=""></div>
    </body>
    
    <!-- the main function would also have the php 
         statement found on line 7 above but will 
         not work... -->
    <!-- i.e. main.php -->
    <!--    <?php $greet->sayHello(); ?> -->
    <!-- both the shell page and template page are -->
    <!-- .php extension -->

CSS

/* Greet.php file */
<?php

class Greet {
    public function sayHello() {
        echo "Hello World!!!";
    }
}

JavaScript

'use strict';

var testApp = angular.module('testApp', []);

testApp.config(['$routeProvider', function($routeProvider) {
    $routeProvider.
      when('/', {
        templateUrl: 'main.php',
        controller: 'MainController'
      }).
      otherwise({
        redirectTo: '/addOrder'
      });
  }]);

testApp.controller('MainController', function($scope) {
    console.log("Inside MainController');
});