简体   繁体   中英

Tried to load angular more than once in Angular js

problem

  • i was using jquery with angular js .

error

angular.js?v=1.6.10_1474366451:12116 TypeError: ha is not a function
at eval (eval at <anonymous> (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:2:2616), <anonymous>:17:349)
at eval (eval at <anonymous> (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:2:2616), <anonymous>:308:401)
at http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:2:2616
at Function.globalEval (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:2:2627)
at text script (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:4:26788)
at Qc (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:4:18505)
at x (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:4:21926)
at b (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:4:26298)
at Object.send (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:4:26402)
at Function.ajax (http://localhost/weblogs-s2/web/common/assets/libs/jquery/jquery.min.js?v=1.6.10:4:21703) <div id="wrapper" ui-view="" class="container ng-scope">(anonymous function) @ angular.js?v=1.6.10_1474366451:12116(anonymous function) @ angular.js?v=1.6.10_1474366451:8976invokeLinkFn @ angular.js?v=1.6.10_1474366451:8527nodeLinkFn @ angular.js?v=1.6.10_1474366451:8034compositeLinkFn @ angular.js?v=1.6.10_1474366451:7435publicLinkFn @ angular.js?v=1.6.10_1474366451:7309updateView @ angular-ui-router.js?v=1.6.10_1474366451:2733(anonymous function) @ angular-ui-router.js?v=1.6.10_1474366451:2697$broadcast @ angular.js?v=1.6.10_1474366451:15893$state.transition.resolved.then.$state.transition @ angular-ui-router.js?v=1.6.10_1474366451:2114processQueue @ angular.js?v=1.6.10_1474366451:14347(anonymous function) @ angular.js?v=1.6.10_1474366451:14363$eval @ angular.js?v=1.6.10_1474366451:15574$digest @ angular.js?v=1.6.10_1474366451:15385$apply @ angular.js?v=1.6.10_1474366451:15679done @ angular.js?v=1.6.10_1474366451:10166completeRequest @ angular.js?v=1.6.10_1474366451:10338requestLoaded @ angular.js?v=1.6.10_1474366451:10279

Failed to parse SourceMap: http://localhost/weblogs-s2/web/metisMenu.js.map

      <div id="wrapper" ui-view="" class="container ng-scope">

angular js code

 var sbAdmin2 = angular.module('sbAdmin2', ['ui.router','ngSanitize']);


sbAdmin2.config(function($stateProvider, $urlRouterProvider) {

$urlRouterProvider.otherwise('');

$stateProvider

    // HOME STATES AND NESTED VIEWS ========================================
    .state('Dashboard', {
        url: '/dashboard/data',
        templateUrl: 'http://localhost/weblogs-s2/web/weblogs_dev.php/dashboard/data'
    })

   })

script i have used

 <html>
  <head>
    <script src="{{ asset ('common/assets/libs/jquery/jquery.min.js') }}?v={{ app_version }}"></script>
     <script src="{{ asset ('common/assets/libs/jquery/jquery-ui/js/jquery-ui.min.js') }}?v={{ app_version }}"></script>
     <script src="{{asset('common/assets/libs/angular/source/angular.js') }}?v={{ app_version }}_{{ NOW }}"></script>
     <script src="{{ asset ('common/assets/libs/angular/source/modules/angular-ui-router.js') }}?v={{ app_version }}_{{ NOW }}"></script>
     <script src="{{ asset ('common/assets/libs/angular/source/modules/angular-sanitize.js') }}?v={{ app_version }}_{{ NOW }}"></script>
 </head>
  <body>
  <div id="wrapper" ui-view class="container ng-scope" >
   </div>
 </body>
</html>

i have googled

  • jquery conflicting with angular js library.
  • when i load angular js before jquery application works fine.
  • but i need to populate the data in datatable then datatable is is not working.
  • which means for datatable require jquery to first to first load.

what i need

  • is it possible to load jquery before angular js library or it may conflicts.

     problem arise when i was using datatable using jquery then it would not work when i used jquery after angular js. 

any suggestion is most welcome

Angular v1.3 only supports jQuery v2.1 and above

Angular 1.3 only supports jQuery 2.1 or above. jQuery 1.7 and newer might work correctly with Angular but we don't guarantee that.

Source: https://docs.angularjs.org/misc/faq

It looks like you are using jQuery v1.6.10 (if that even exists). Try updating to a newer version of jQuery.

(Also make sure you're using Angular v1.* and not Angular v2.*)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM