How to use the angular.fromJson function in angular

To help you get started, we’ve selected a few angular examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spring-projects / spring-flo / tests / resources / metamodel-service.js View on Github external
return $http.get('/parse', { params: {'text': definitionText}}).success(function(data) {
				if (angular.isFunction(setErrorFn)) {
					setErrorFn(null);
				}
				if (typeof data === 'string') {
					data = angular.fromJson(data);
				}
				// TODO handle error case, clear the graph
				$log.info('parse responded with data:\''+JSON.stringify(data)+'\'');
				if (angular.isFunction(updateGraphFn)) {
					updateGraphFn(data);
				}
			}).error(function(data, status, headers, config, statusText) { // jshint ignore:line
				if (typeof data === 'string') {
github latestchatty / chatty / src / old / main / services / tabService.js View on Github external
}
                })
            }
        }

        function save() {
            var filtered = _.filter(_.cloneDeep(tabs), tab => !!tab.tabType)
            var cleaned = _.map(filtered, tab => ({
                tabType: tab.tabType,
                value: tab.value
            }))
            localStorageService.set('tabs', cleaned)
        }

        //load on startup
        var loaded = angular.fromJson(localStorageService.get('tabs')) || []
        _.each(loaded, tab => tabService.addTab(tab.tabType, tab.value))
        return tabService
    }
github the-front / angularjs-ee-boilerplate / src / app / bookmarks / mock / url-interceptors.js View on Github external
.respond(function(method, url, data) {
        console.debug('POST ' + url);

        data = angular.fromJson(data);
        data = collection.insert(data);

        console.debug(data);

        return [201, angular.copy(data)];
      });
github SharePoint / sp-dev-fx-webparts / samples / angular-msgraph / src / webparts / msGraph / app / HomeController.ts View on Github external
let expiration: Date = new Date();
    expiration.setTime((auth.expires - 300) * 1000);
    if (expiration > new Date()){
      this.$http.defaults.headers.common.Authorization = 'Bearer ' + auth.access_token;
      this.$http.defaults.headers.common.SampleID = 'angular-connect-rest-sharepoint';

      if (localStorage.getItem('user') === null){
        this.graphHelper.me().then((results: any): void => {
          let user = results.data;
          localStorage.setItem('user', angular.toJson(user));

          this.displayName = user.displayName;
        });
      }
      else {
        let user = angular.fromJson(localStorage.getItem('user'));

        this.displayName = user.displayName;
      }
    }
  }
github SharePoint / sp-dev-fx-webparts / samples / angular-msgraph / src / webparts / msGraph / app / HomeController.ts View on Github external
private _processAuth(){
    let auth: any = angular.fromJson(localStorage.getItem('auth'));

    let expiration: Date = new Date();
    expiration.setTime((auth.expires - 300) * 1000);
    if (expiration > new Date()){
      this.$http.defaults.headers.common.Authorization = 'Bearer ' + auth.access_token;
      this.$http.defaults.headers.common.SampleID = 'angular-connect-rest-sharepoint';

      if (localStorage.getItem('user') === null){
        this.graphHelper.me().then((results: any): void => {
          let user = results.data;
          localStorage.setItem('user', angular.toJson(user));

          this.displayName = user.displayName;
        });
      }
      else {
github spinnaker / deck / app / scripts / modules / core / serverGroup / serverGroup.write.service.spec.js View on Github external
$httpBackend.expectPOST(API.baseUrl + '/applications/appName/tasks', function (bodyString) {
        submitted = angular.fromJson(bodyString);
        return true;
      }).respond(200, {ref: '/1'});
github angular-gantt / angular-gantt / demo / demo.controller.ts View on Github external
let listenRowJson = ganttDebounce(function (rowJson) {
    if (rowJson !== undefined) {
      let row = angular.fromJson(rowJson)
      objectModel.cleanRow(row)
      let tasks = row.tasks

      delete row.tasks
      delete row.drawTask

      let rowModel = $scope.live.row

      angular.merge(rowModel, row)

      let newTasks = {}
      let i
      let l

      if (tasks !== undefined) {
        for (i = 0, l = tasks.length; i < l; i++) {
github SharePoint / sp-dev-fx-webparts / samples / angular-msgraph / src / webparts / msGraph / app / HomeController.ts View on Github external
public getListItems(listId: string): void {
    let auth: any = angular.fromJson(localStorage.getItem('auth'));
    let expiration: Date = new Date();
    expiration.setTime((auth.expires - 300) * 1000);

    if (expiration > new Date()){
      this.graphHelper.getListItems(this._siteId, listId).then((results: Array): void => {
        this.$log.debug(results);
        this.vwLsts = false;
        this.vwLstItm = true;
        this.itemCollection = results;
        this._listId = listId;
      });
    }
    else {
      this.graphHelper.login();
    }
  }
github SharePoint / sp-dev-fx-webparts / samples / angular-msgraph / src / webparts / msGraph / app / HomeController.ts View on Github external
public getLists(siteId: string): void {
    let auth: any = angular.fromJson(localStorage.getItem('auth'));
    let expiration: Date = new Date();
    expiration.setTime((auth.expires - 300) * 1000);

    if (expiration > new Date()){
      this.graphHelper.getLists(siteId).then((results: Array): void => {
        this.$log.debug(results);
        this.vwSC = false;
        this.vwLsts = true;
        this.listCollection = results;
        this._siteId = siteId;
      });
    }
    else {
      this.graphHelper.login();
    }
  }