I would like to change a phrase string into an array of word string in angularjs. For example i would like to transform $scope.phrase='come back home'
to $scope.words=['come','back','home']
Can you please help
I would like to change a phrase string into an array of word string in angularjs. For example i would like to transform $scope.phrase='come back home'
to $scope.words=['come','back','home']
Can you please help
You need to use split method.
Split
method splits a String object into an array of strings.
$scope.words=$scope.phrase.split(' ');
Here is a working solution.