Хорошо, у меня есть главный контроллер и другой, где я расширяю основной (для отображения другого макета).
Основной контроллер:
function CustomerInformationController(...) {
var vm = this;
...
vm.save = function() {
if (angular.isDefined(vm.guestAccountForm)) {
...
}
...
Основной шаблон:
<div ng-controller="CustomerInformationController as customerInformation" class="customer-information">
<form name="customerInformation.guestAccountForm">
...
</form>
</div>
Контроллер расширения:
function CustomerInformationControllerExtent($controller, $scope) {
var vm = this;
// Extend Product Controller.
angular.extend(this, $controller('CustomerInformationController', { $scope: $scope }));
Расширение шаблона (я хочу изменить этот шаблон и переопределить его):
<div ng-controller="CustomerInformationControllerExtent as customerInformation" class="customer-information">
<form name="customerInformation.guestAccountForm">
...
</form>
</div>
Когда я использую толькоосновной элемент управления все в порядке, но в расширении контроллера, когда я пытаюсь проверить правильность формы, vm.guestAccountForm
не определено.
НО, когда я пытаюсь с this
(this.guestAccountForm
)все в порядке.
Я что-то упустил с функцией расширения?