Error: “Selectors not implemented”

后端 未结 1 1735
清歌不尽
清歌不尽 2020-12-30 00:54

I\'m having difficulty selecting an element with angular. I must be making some silly mistake:

function Root($scope) {
    $scope.elem = angular.element(\'d         


        
相关标签:
1条回答
  • 2020-12-30 01:30

    It's because jquery needs to be referenced before angular. JSFiddle registered Angular 1.0.2 FIRST and then the jquery verson you added as a resource.

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script src="//ajax.googleapis.com/ajax/libs/angularjs/1.0.2/angular.min.js"></script>
    

    This way Angular knows it can use JQuery and not JQLite. Once you do this, the selector will work in angular.element()

    Here's your fiddle, updated to reference the scripts in the right order (and altered slightly, see the comments)

    If you don't have JQuery, you can select the DOM Element manually.

    var div = document.querySelector('div');
    $scope.elem = angular.element(div);
    
    0 讨论(0)
提交回复
热议问题