* @param data
*/
function sendRequestData(data, type){
- $scope.rootBroadcast('YANGMAN_SET_CODEMIRROR_DATA_' + type, { data: JSON.stringify(data, null, 4) });
+ $scope.rootBroadcast(
+ 'YANGMAN_SET_CODEMIRROR_DATA_' + type,
+ { data: data instanceof Object ? JSON.stringify(data, null, 4) : data }
+ );
}
function sendErrorData(response) {
* @returns {string}
*/
function setDataForView(data){
- var newData = {},
- parsedData = '';
+ var result = '';
+
+ if (data instanceof Object) {
+ result = JSON.stringify(
+ YangUtilsService.stripAngularGarbage(
+ angular.copy(data),
+ self.getLastPathDataElemName()
+ ),
+ null,
+ 4
+ );
+ }
+ else {
+ result = data;
+ }
- angular.copy(data, newData);
- parsedData = JSON.stringify(
- YangUtilsService.stripAngularGarbage(newData, self.getLastPathDataElemName()), null, 4);
+ return result;
- return parsedData;
}