Tag: AngularJS
-
Select Not Showing Selected Values – AngularJs
Hey everyone, I had a bit of trouble getting a selected option to show up with AngularJs. It turned out that I needed to add an ng-selected attribute: {{command.Status}} Enabled Disabled Deleted Check out this Stackoverflow post for more info: http://stackoverflow.com/a/18336858/522859
-
angular js calling services twice – Angular JS
Hey everyone, I had a few of my AngularJS services being called twice. The issue turned out to be that I’d added a controller to both my route and my view: app.config(function ($routeProvider) { $routeProvider .when(‘/’, { controller: ‘ProjectsController’, /* <—- here */ templateUrl: '/Home/Home' }) <!– {{project.Name}} Removing it from the controller resolved the…
-
Error: $injector:modulerr Module Error – AngularJS
Hey everyone, Just getting back into angularjs and I came across the following error: Unknown provider: $routeProvider It turns out I that while I had included the route provider file I had missed adding it to the app: //Original var app = angular.module(‘commandsApp’, [‘]); //Fixed var app = angular.module(‘commandsApp’, [‘ngRoute’]); Check out the following links…
-
Random Class Directive – AngularJS
Hey everyone, Just another small directive. This one adds a random class from the provided array to the element. Check out this fiddle to see the demo: http://jsfiddle.net/uvSVj/3/ I used this directive to add a random background to each of my wrapper divs: To use it in your app simply define a list of classes…
-
Route Parameters – AngularJS
Hey everyone, This is just a quick post on what I did to get my routes working properly with AngularJS. My routes looked like this: //Configure routes app.config(function ($routeProvider) { $routeProvider //… .when(‘/Businesses/Details/:id’, { templateUrl: ‘/Businesses/Details’ }) //… .otherwise({ redirectTo: ‘/’ }); }); And then to access the ID parameter I used $routeParams: /* Used…
-
TimeSelector / TimePicker Directive – AngularJS
Hey everyone, I’ve been mucking around with directives for that last few days and one of my requirements has been a simple timepicker. Nothing too fancy, but if anyone would like to use it – feel free. See the following fiddle for the demo: http://jsfiddle.net/LFB3F/2/ The directive is initialised with both the hour and minute…
-
Passing Parameters from a Directive to a Function – AngularJS
Hey everyone, This is just a quick post to help out anyone who runs into the same problems with directives that I did today. I was able to call the controllers function from the directive, however none of the parameters were being passed. The issue ended up being that the parameters need to be named.…
-
Select List (ng-select) – AngularJS
Hey everyone, Just a quick post on how to do up a select list in AngularJS. This one took a bit of time to work out, particularly the display/value pairing. HTML: Status: JavaScript: var myApp = angular.module(‘myApp’, []); function MyCtrl($scope) { $scope.status_options = [ { display: ‘Enabled’, value: ‘enabled’ }, { display: ‘Disabled’, value: ‘disabled’…
-
Forcing a Link to Behave Normally – AngularJS
Hey everyone, Another quick post. Working with AngularJS this morning I had a need for a link to redirect to a login page that was not contained within the “angular” part of the app. Unfortunately Angular was overriding the behavior and trying to route it. The solution is fairly easy for this, simply add a…
-
JSON Issue: This request has been blocked because sensitive information – MVC
Hey everyone, Started redoing Learner Lessons in MVC4 and AngularJS today. I ran into this little issue while trying to retrieve JSON: This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet It…