AngularJS: ng-bind with whitespaces

Used by http://stackoverflow.com/q/23633434/1521227

by Markus Rehrs

HTML

<div ng-app>
    <div ng-controller="MyCtrl">
        Output: "{{input}}"<br />
        <input type="text" ng-model="rawInput" placeholder="Enter text here" ng-change="onInputChanged()" />
    </div>
</div>

JavaScript

var myApp = angular.module('myApp', []);

function MyCtrl($scope) {
    $scope.input = '';
    $scope.rawInput = '';
    $scope.onInputChanged = function () {
        $scope.input = $scope.rawInput.replace(/\s/g, '*');
    };
}