Search Posts

Author: Sabnekar Rajnikant

$location is not defined in angularjs

In the below , roles.js file whenever the onSelect function is called if the role is UserRole i’m navigating user to different page angular.module(‘myApp.roles’, [‘ngRoute’]) .config([‘$routeProvider’, function ($routeProvider) { $routeProvider.when(‘/roles’, { templateUrl: ‘roles/roles.html’, controller: ‘PostsCtrl’, selector: ‘roles’ }); $routeProvider.when(‘/footer’, { templateUrl: ‘footer/footer.html’, controller: ‘footerCtrl’ }); }]) .controller(‘PostsCtrl’, [‘$scope’, ‘$rootScope’, ‘$location’, function ($scope, $rootScope, $log, $location) { $scope.onSelect = function (A, B, C) { localStorage.setItem(“A”, JSON.stringify(A)); localStorage.setItem(“B”, JSON.stringify(B)); localStorage.setItem(“C”, JSON.stringify(C)); if (role.roleName === “User Role”) { […]

how to compare strings with ng-if?

In the below code, i’m getting environments from localStorage which i had stored earlier and assigning it to $scope.environments. When the accessMethod is “A” then it should show button and when accessMethod is “B” it should show a dropdown. <form accept-charset=”UTF-8″ role=”form” name=”loginForm” ng-controller=”PostsCtrl” novalidate ng-submit=”Onsubmit()” > <fieldset> <ul class=”heroes” ng-repeat=”environment in environments track by $index” > <li ng-if=”environment.accessMethod === ‘A'”> <button type=”button” class=”btn btn-primary” uib-dropdown-toggle ng-disabled=”disabled”> <span class=”badge”>{{environment.code}}</span> </button> </li> <li ng-if=”environment.accessMethod === ‘B'”> […]