2
是否有方法僅在某個Angularjs控制器/視圖中調用jQuery函數? 例如,我只想在主視圖中調用幻燈片功能。通過角度視圖調用jQuery函數
幻燈片:
$('.slides').superslides();
app.js:
var myApp = angular.module('myApp', ['ngRoute']);
myApp.config(['$routeProvider', '$locationProvider', function($routeProvider, $locationProvider) {
$routeProvider
.when('/', {
templateUrl : 'views/home.html',
controller : 'mainController'
});
$locationProvider.html5Mode(true).hashPrefix('!');
}]);
myApp.controller('mainController', function($scope, $location, $anchorScroll) {
$scope.scrollTo = function(id) {
$location.hash(id);
$anchorScroll();
}
});
無需分離範圍會更好 – floribon