I am currently editing text in a textarea within the admin view and I would like to display it through an angular service on the user view. However, I want the text to be displayed in multiple rows, maintaining the same format that I entered in the textarea. This textarea and button are located in the admin view
<textarea name="" id="textAreaAbout" cols="50" rows="10" ng-model="aboutAdmin.about"></textarea>
<button type="button" class="btn-primary" ng-click="aboutAdmin.saveAboutBtn(aboutAdmin.about)">Save</button>
service
app.factory('global', function(){
let _items = [
'Hi, my name is Pavlo Lapan and I am front-end developer from Ukraine.',
'I have got more than 1 years of experience in web development. I think my strong points are dedication, punctuality and easy in communication',
'Right now I am on the third year of studying at Software Engineering specialization in Lviv National University, in Ukraine.',
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci architecto aspernatur, distinctio doloribus error et maxime tempore? Ducimus, exercitationem sed.',
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci architecto aspernatur, distinctio doloribus error et maxime tempore? Ducimus, exercitationem sed.',
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci architecto aspernatur, distinctio doloribus error et maxime tempore? Ducimus, exercitationem sed.',
'Lorem ipsum dolor sit amet, consectetur adipisicing elit. Adipisci architecto aspernatur, distinctio doloribus error et maxime tempore? Ducimus, exercitationem sed.'
];
let _itemId = 1;
return {
getItems: function(){
return _items;
},
getItemId: function(){
return _itemId;
},
setItemId: function(itemId){
if(itemId<_itemId) alert('error')
else _itemId = itemId;
},
setItems: function (items) {
_items = items;
}
}
})
controller
app.controller('aboutAdminCtrl', function(global){
let vm = this;
vm.about = global.getItems();
vm.saveAboutBtn = function (text) {
console.log(vm.about);
vm.about = text;
console.log(vm.about);
global.setItems(vm.about);
}
})
user view
<p ng-repeat="text in about.about track by $index">{{text}}</p>
User Controller
app.controller('aboutCtrl', function(global){
let vm = this;
vm.about =[];
vm.about = global.getItems();
})