如题
angularjs 中 控制器,服务,指令3者的区别是什么啊!看书这三个概念好晕
PHPz2017-05-15 16:57:49
Controller is responsible for the main logic of the page. Directive is similar to the concept of web components. It takes out a part of the page and encapsulates it into a Directive that is referenced in the page through tags. A Directive contains the HTML template and business logic of this component. Service abstracts functions independently and uses them flexibly through dependency injection
PHP中文网2017-05-15 16:57:49
Simply can be understood as controller: controlling data interaction and simple page interaction. If page interactions become complex, they can be extracted separately and encapsulated into instructions, and the service can provide commonly used data request services. Of course, these are just the tip of the iceberg. If you dig deeper, you will find that they have far more functions than these~