javascript - Call jQuery function by Angular view -
is there way call jquery function in angularjs controller/view? example, want call slides function in home view.
slides:
$('.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(); } });
create directive.
js:
myapp.directive( "superslides", function() { return { restrict: "a", scope: {}, link: function ( scope, element, attrs ) { $( element ).superslides(); } } } ) html:
<ul superslides> </ul>
Comments
Post a Comment