Coding practice with angularjs