zoukankan      html  css  js  c++  java
  • angularjs取Sevice和directive的引用

    取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.

  • 相关阅读:
    CentOS 7 安装java 环境
    CentOS 7 替换网易yum 源
    九度:题目1553:时钟
    Maximum Subarray
    职场细节
    poj2524 Ubiquitous Religions
    九度 1526:朋友圈
    程序载入
    设备管理
    操作系统系列
  • 原文地址:https://www.cnblogs.com/yoyogis/p/3820019.html
Copyright © 2011-2022 走看看