Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sir Trevor Issues In Angular 2 #525

Closed
borntodesign opened this issue Jan 11, 2017 · 2 comments
Closed

Sir Trevor Issues In Angular 2 #525

borntodesign opened this issue Jan 11, 2017 · 2 comments

Comments

@borntodesign
Copy link

borntodesign commented Jan 11, 2017

  1. Has anyone got this working yet?
  2. If not I am having a few issues so I think I will just paste my code and someone can tell me what I am doing wrong.

Pages Controller


// Import for forms and validations
import { FormGroup, FormControl, FormBuilder, Validators } from '@angular/forms';

declare var SirTrevor: any; // declared as any, so anything goes

@Component({
  selector: 'app-pages',
  templateUrl: './pages.component.html',
  styleUrls: ['./pages.component.css']
})
export class PagesComponent implements OnInit, OnDestroy {
  editor: any;

  public pageForm: FormGroup; // our model driven form

  constructor() {
    SirTrevor.setDefaults({
      iconUrl: "../assets/sirtrev/sir-trevor-icons.svg"
    });
    SirTrevor.setDefaults({
      uploadUrl: "https://api.cloudinary.com/v1_1/property-roland/image/upload?upload_preset=n3fxornt",
      attachmentName: 'name',
      attachmentFile: 'file',
      attachmentUid: 'uid'
    });
  }

  ngOnInit() {
    // Load initiail blank form group
    this.pageForm = new FormGroup({
    });
    
    if(!this.editor) {
      this.editor = new SirTrevor.Editor({
        el: document.getElementById('sir-editor'),
        defaultType: 'Text',
        iconUrl: '../assets/sirtrev/sir-trevor-icons.svg'
      });
    }
  }
  ngOnDestroy() {
    if(this.editor) {
      this.editor.destroy();
      this.editor = undefined;
    }
  }
  getData() {
    console.log(this.editor.store.retrieve());
    console.log(this.editor.store.toString());
    console.log(this.editor);
  }

}

Pages View

<form [formGroup]="pageForm" (ngSubmit)="getData()" novalidate>
  <textarea id="sir-editor"></textarea>
  <button type="submit" class="btn btn-primary">Data</button>
</form>

The thing is that the data only shows when I click submit twice (weird). Then when I navigate away and come back it does not show any data on save after adding new content.

@raffij
Copy link
Contributor

raffij commented Jun 7, 2017

@borntodesign assume you found a way to get it working, but there's an old comment which would have helped you.

#393 (comment)

@raffij raffij closed this as completed Jun 7, 2017
@borntodesign
Copy link
Author

borntodesign commented Jun 7, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants