search

Home  >  Q&A  >  body text

javascript - Both angular and jquery use the $ symbol, will there be any conflict if used together?

For example, $scope.op = $('#box'), the two $ before and after belong to different libraries. . Will there be any problem

世界只因有你世界只因有你2746 days ago934

reply all(6)I'll reply

  • 漂亮男人

    漂亮男人2017-06-14 10:52:38

    No.
    $ in jQuery is equivalent to jQuery being a variable $scope
    in angular, $http, etc. are also separate variableswhere $ is just a part of the variable name, such as var $abc = 'abc'
    where $ will not conflict with $ in jQuery

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-14 10:52:38

    I don’t think so

    reply
    0
  • 迷茫

    迷茫2017-06-14 10:52:38

    $scope and $ are two completely different variable names that have no relationship. . .

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-06-14 10:52:38

    No way~
    $scope You can treat it as an object... $ It’s another object
    like var abc=1; var a=2; There will be no conflict between these two objects.. .

    reply
    0
  • 阿神

    阿神2017-06-14 10:52:38

    The

    $ in $scope is just a prefix of a variable and has nothing to do with $. The $ in jQuery is a real variable.

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-06-14 10:52:38

    You can redefine a symbol for jQuery and release the control of $,
    For example:
    `var $j = jQuery.noConflict();
    $j(".box").on("click",function(){ //code});
    `

    reply
    0
  • Cancelreply