Angular newbie here.
This may be a dumb/trivial question, but I'm really trying to learn Angular, even though I feel like I could hand-code this stuff faster. I have this app that is trying to mimic an old computer console. The user can type in whatever he wants and when he presses Enter, the command is displayed above, and possibly some action is performed, depending on the command given. Basic command prompt-type look and feel.
Here is a JSFiddle. Please excuse the CSS issues; I couldn't quite get everything looking correctly.
Basically, I have an invisible form with a text field and submit button. Jquery keeps the text input in focus, and when the user types some input, Angular binds it to a formatted DOM element. The issue is that the input field is sluggish in displaying the input, which in turn causes a delay in being displayed on-screen. When I remove the Angular code, the text input is snappy and responsive. Any help would be appreciated. Here is the code that causes the slowdown. I can't find anything particularly wrong with it.
angular.module("kendall").controller("ConsoleController", ['$scope', '$interval', '$timeout', function($scope, $interval, $timeout) {
// Add new command to list.
$scope.pushCommand = function($command) {
if(!$command) {
$command = 'ERROR! NO INPUT...';
}
$('#current-input').before('<p class="command">' + $command + '</p>');
$scope.text = '';
$('#new-command').focus();
};
//////////////////////////
///// MAIN SCRIPT /////
//////////////////////////
$scope.commands = [];
$scope.timer = null;
$scope.periodDelay = 5; // Number of 'typeDelay' cycles to wait after period is submitted.
$scope.typeCounter = $scope.pause = 0;
$scope.begin = new Date();
}]);
HTML -
<div class="monitor-inner">
<div class="monitor-screen col-xs-10 col-xs-offset-1">
<div class="col-xs-12 bevelled"></div>
<div class="col-xs-12 lined"></div>
<div class="content-bubble col-xs-12" ng-controller="ConsoleController as console">
<form ng-submit="pushCommand(text)">
<input type="text" id="new-command" ng-model="text" />
<input type="submit" />
</form>
<p id="current-input">{{ text }}<span class="block"></span></p>
<div class="display-row">
<button>About Me</button>
<button>Website</button>
<button>Top Secret</button>
</div>
<div class="touch-row">
<button>About Me</button>
<button>Website</button>
<button>Top Secret</button>
</div>
</div>
</div>
</div>
Thanks for your help!