Наследование в контроллере Angular

{% raw %}<div ng-controller="BMWController">
    My name is {{ name }} and I am a {{ type }}
    <button ng-click="clickme()">Click Me</button>
</div>{% endraw %}
function CarController($scope) {

    $scope.name = 'Car';
    $scope.type = 'Car';

    $scope.clickme = function() {
        alert('This is parent controller "CarController" calling');
    }
}

function BMWController($scope, $injector) {

    $injector.invoke(CarController, this, {$scope: $scope});

    $scope.name = 'BMW';
}

Теги: javascript , angularjs , сниппет