Focus-when
(function () {
'use strict';
angular.module('simpleChatApp')
.directive('focusWhen', focusWhen);
function focusWhen() {
return {
link: link
};
function link(scope, element, attrs) {
scope.$on(attrs.focusWhen, function (event) {
element[0].focus();
event.preventDefault();
})
}
}
})();
form.input-group(ng-submit="addMessage(newMessage); $broadcast('form:change');")
input#btn-input.form-control.input-sm(type='text', placeholder='Type your message here...', ng-model='newMessage', focus-when='form:change')
span.input-group-btn
button#btn-chat.btn.btn-warning.btn-sm(type='submit')
| Send