LoginSignup
18
17

More than 5 years have passed since last update.

AngularJS と jQuery を併用するとき

Posted at

AngularJSのソースをちょっと覗いたときに気がついたのですが、angular.element の実体は通常 jQueryLite なんですが、window.jQuery が設定されてる(jQuery読みこまれてる)と、jQueryを拡張して、angular.element にするんですね!

ドキュメントに書いてなかったよーなと思ってドキュメント見たら、ちゃんと書いてありましたw

angular.module("mymodule", []).directive("foo", ->
    {
        restrict: 'CA'
        link: (scope, element, attrs)->
            nexts = jQuery(element).nextAll()
            #ごにょごにょ
            return
    }
)

とか書いてたところは

angular.module("mymodule", []).directive("foo", ->
    {
        restrict: 'CA'
        link: (scope, element, attrs)->
            nexts = element.nextAll()
            #ごにょごにょ
            return
    }
)

って形に直そう...

18
17
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
18
17