You basically do the same but in the directive's link function.