Posts

Node.js Express, form validation, and keeping previously posted form values

I've been playing with Node.js and the Express webserver framework as a learning experience, it's good fun :) In the C# ASP MVC world using the Razor view engine I can define my user interface elements like this... @Html.TextBoxFor(x => x.EmailAddress) @Html.ValidationMessageFor(x => x.EmailAddress) This will do three things It will create the html output for an input element If the view is being rendered as a result of a POST it will set the value of the input to the value posted.  This is useful for when you have a form validation error and don't want to have to force the user to re-enter all of their input. If there is an error message registered for EmailAddress it will display the error text *Note that error messages are registered using ModelState.AddModelError("EmailAddress", "The error message") Node.js, Express, and Jade Express is a very light weight framework so doesn't do any of this stuff for you, so I had to h

AngularJS - Triggering code whenever ng-view updates

//Create the module var app = angular.module('someapp', ['ngRoute']); //Config the routes app.config(configRoutes); function configRoutes($routeProvider) { $routeProvider .when('/', { templateUrl: '/angular/viewtemplates/admin/index.html', controller: 'AdminController' }) .when('/categories', { templateUrl: 'angular/viewtemplates/admin/categories/index.html', controller: 'CategoryIndexController' }) } //Make sure we are notified whenever the ng-view is updated app.run(function($rootScope) { $rootScope.$on('$viewContentLoaded', function() { $('table[data-toggle="table"]').bootstrapTable(); }); });