ارث بری کنترلرها در AngularJs
نویسنده: مسعود پاکدل
تاریخ: ۱۳۹۲/۰۹/۲۸ ۱۵:۵
آدرس: www.dntips.ir
| مطالب | ۳۶۹۴ |
| نویسندگان | ۲۷۶ |
| گروههای مطالب | ۱۰۲۴ |
| نقشههای راه | ۱۱۹ |
| دورهها | ۱۴ |
| اشتراکها | ۱۷۹۱۴ |
var app = angular.module('myApp', []);
app.controller('parentController', function () {
this.title = 'Title from parent controller';
})
app.controller('childController', function () {
this.title = 'Title from child controller';
}) <div ng-app="myApp">
<div ng-controller="parentController as parentCtrl">
<div ng-controller="childController as childCtrl">
<input type="text" ng-model="parentCtrl.title" size="100"/>
<input type="text" ng-model="childCtrl.title" size="100"/>
</div>
</div>
</div>
<div ng-app="myApp">
<div ng-controller="parentController as parentCtrl">
<div ng-controller="childController as childCtrl">
<input type="text" ng-model="parentCtrl.title" size="100"/>
<input type="text" ng-model="parentCtrl.title" size="100"/>
</div>
</div>
</div>
نکته: دسترسی به کنترلر child در کنترلر parent امکان پذیر نیست.