2015-05-10 120 views
2

我正在使用angularjs和jquery(對於菜單和更多),但我不知道爲什麼我不能讓jquery(eq。簡單手風琴菜單)像this一樣工作,都在<div ng-view>我嘗試了所有方法,但並沒有工作,請幫我jquery不工作ngview裏面

這是我的角碼

var myApp = angular.module("myApp",['ngRoute']); 
     $url ="/load.php?stundent=<? echo $_GET["all"]; ?>"; 
      myApp.factory('myService',function($http){  
        var getData = function() { 
      return $http({method:"GET", url:$url}).then(function(result){ 
       return result.data; 
      }); 
     }; 
     return { getData: getData }; 
    }); 


    myApp.config(function($routeProvider) { 
      $routeProvider 
       .when('/', { 
        templateUrl : 'main.html', 
        controller : 'ItemsController' 
       }) 
       // route for the home page 
       .when('/one', { 
        templateUrl : 'one.html', 
        controller : 'ItemsController' 
       }) 

       // route for the about page 
       .when('/two', { 
        templateUrl : 'p/two.html', 
        controller : 'othercontroller' 
       }); 
     }); 
    myApp.controller('othercontroller', function othercontroller($scope,$http) { 
    ... 
    }); 

myApp.controller('ItemsController', function ItemsController($scope,myService,$timeout,$http) { 
... 
} 
+0

如果你必須使用該jQuery(可以很容易地用角度來完成),你需要把它放在一個指令中。裏面的指令,你有權訪問主元素,它的後代 – charlietfl

+0

什麼「它不工作」是什麼意思?請爲您的問題添加詳細信息,說明您希望代碼執行的內容以及實際執行的內容。 – Cristik

+0

菜單不收縮,當我點擊什麼時候什麼也沒有發生 – jearca

回答

0

如果使用jQuery是可選的你,我建議使用UI引導或AngularStrap這樣的事情。正如其他人所說,自定義指令將允許您使用jQuery。
Here's an example from another question

相關問題