Sir Trevor Issues In Angular 2
borntodesign opened this issue · 2 comments
borntodesign commented
- Has anyone got this working yet?
- 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 commented
@borntodesign assume you found a way to get it working, but there's an old comment which would have helped you.
borntodesign commented
I just used something else in the end, thanks anyway.
…On Wed, Jun 7, 2017 at 12:15 PM, Raffi Jacobs ***@***.***> wrote:
Closed #525 <#525>.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#525 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AEUSGjzlbICaekpz5sRKpg8CNNeDF_qpks5sBoZdgaJpZM4Lgwvb>
.