取Sevice和directive的引用

3: Grab any Services

We can grab a reference to any service using the injector function of element where ngApp was defined (or grab the $rootElement manually if using angular's bootstrap method):

> angular.element('html').injector().get('MyService')
-> Object {undo: function, redo: function, _pushAction: function, newDocument: function, init: function…}

We can then call methods on that service just like we could if we injected it.

4: Access controller for directive

Some directives define a controller with certain additional (often shared) functionality. To access the instance of a controller for a given directive from the console, just use the controller() function:

> angular.element('my-pages').controller()
-> Constructor {}

This last one is more advanced and not used as frequently.

angularjs取Sevice和directive的引用的更多相关文章

  1. AngularJS系统学习之Directive(指令)

    本文转自https://www.w3ctech.com/topic/1612 原文作者: Nicolas Bevacqua 原文:AngularJS’ Internals In Depth, Part ...

  2. angularjs可交互的directive

    angularjs可交互的directive http://jsfiddle.net/revolunet/s4gm6/ directive开发上手练手,以注释的方式说明 html <body n ...

  3. AngularJS入门心得1——directive和controller如何通信

    粗略地翻了一遍<JavaScript DOM编程艺术>,就以为可以接过AngularJS的一招半式,一个星期过去了,我发现自己还是Too Young,Too Simple!(刚打照面的时候 ...

  4. AngularJs(Part 11)--自定义Directive

    先对自定义Directive有一个大体的映像 myModule.directive('myDirective',function(injectables){ var directiveDefiniti ...

  5. AngularJS学习笔记之directive—scope选项与绑定策略

    From:http://www.linuxidc.com/Linux/2015-05/116924.htm scope:{}使指令与外界隔离开来,使其模板(template)处于non-inherit ...

  6. angularjs学习笔记三——directive

    AngularJS 通过被称为 指令 的新属性来扩展 HTML. 正如你所看到的,AngularJS 指令是以 ng 作为前缀的 HTML 属性. HTML5 允许扩展的(自制的)属性,以 data- ...

  7. AngularJS学习笔记之directive——scope选项与绑定策略

    开门见山地说,scope:{}使指令与外界隔离开来,使其模板(template)处于non-inheriting(无继承)的状态,当然除非你在其中使用了transclude嵌入,这点之后的笔记会再详细 ...

  8. 【温故知新C/C++/opencv】取址符&||cv::groupRectangles||引用与值传递

    cv::groupRectangles void groupRectangles(vector<Rect>& rectList, int groupThreshold, doubl ...

  9. AngularJS创建新指令directive参数说明

    var myapp = angular.module('myapp', []); myapp.directive('worldname', function() { return { template ...

随机推荐

  1. 问题记录-Fragment导包不同导致无法自动转型

    代码如下 public class MainActivity extends FragmentActivity { @Override public void onCreate(Bundle save ...

  2. 02-线性结构3 Pop Sequence

    Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and p ...

  3. Python学习教程(learning Python)--2.3.4Python函数返回值

    本节讨论Python函数返回值问题. Python和C语言一样,也可以在函数结束时返回一个值.但在定义自己的Python函数时,是不需要指定返回值数据类型的,这和Python不关心变量的数据类型是一致 ...

  4. MIFARE系列4《组成图》

    MIFARE集成电路芯片内含EEPROM.RF接口和数字控制单元. 1. RF射频接口 在RF射频接口电路中,主要包括有波形转换模块.它可将卡片读写器上的13.56MHZ的无线电调制频率接收,一方面送 ...

  5. android 连续点击退出程序

    package com.test.twiceexit; import java.util.Timer; import android.app.Activity;import android.os.Bu ...

  6. Stream,Reader/Writer,Buffered的区别(1)

    Stream: 是字节流形式,exe文件,图片,视频等.支持8位的字符,用于 ASCII 字符和二进制数据. Reader/Writer: 是字符流,文本文件,XML,txt等,用于16位字符,也就是 ...

  7. centos php-fpm nginx配置

    移除旧的软件包:yum remove httpd* php* 安装:yum install php php-fpm yum install php-gd php-mysql php-mbstring ...

  8. 关于在android4.1.x的版本不能启动支付宝问题

    异常:Failure calling remote service 异常日志: INFO/<unknown>(<unknown>): java.security.spec.In ...

  9. ASP.NET Web API 2 对 CORS 的支持

    CORS概念 跨域资源共享 (CORS) 是一种万维网联合会 (W3C) 规范(通常被认为是 HTML5 的一部分),它可让 JavaScript 克服由浏览器施加的同域策略安全限制. 所谓同域策略, ...

  10. Function-两个日期大小比较

    function checkDate(from,to){ if (from == "" || to == "") return 2; var rValue = ...