# $controller 继承

有的时候需要继承关系，来解决重复代码，通过`$controller`就可以解决

```javascript
var app = angular.module('angularjs-starter', []); 
app.controller('ParentCtrl ', function($scope) {
// I'm the sibling, but want to act as parent
});
app.controller('ChildCtrl', function($scope, $controller) {
$controller('ParentCtrl', {$scope: $scope}); //This works
});
```

## 资料

[AngularJS控制器继承自另一控制器](http://www.jb51.net/article/83836.htm)

[angularjs controller 继承](https://www.cnblogs.com/qiaojie/p/5721098.html)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://xiaoxiami.gitbook.io/angularjs/qi-ta/controller-ji-cheng.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
