Reputation: 388
Hi i am getting 'ReferenceError: $ is not defined' in my code. This is my sample code
$rootScope.$on('$stateChangeStart', function (event, next, current) {
// redirect to login page if not logged in and trying to access a restricted page
var restrictedPage = $.inArray($state.current.name, ['login']) === -1;
var loggedIn = $rootScope.globals.currentUser;
if (restrictedPage && !loggedIn) {
$state.go('login');
}
});
This code am writing inside run();
Upvotes: 0
Views: 22128
Reputation: 25942
If you're using a NodeJS project, you can install jquery, then import the jquery library. e.g.
Console: (run from project root)
npm install jquery
Javascript: (insert in header of your .js
file)
var $ = require('jquery');
Upvotes: 2
Reputation: 11983
Add jquery file in your project. $
means jQuery.
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.js"></script>
Upvotes: 5