-
Notifications
You must be signed in to change notification settings - Fork 42
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
Using with Angular #41
Comments
Yes you can do it, but manually. It's a vanilla library. You have an example using React here, you can take inspiration from it. Basically, you need to add the library in your index.html in the public folder. Once loaded in this file, the library will add a global variable |
Edit: apparently you don't have any problem with Angular. (linking with Drarig29/brackets-manager.js#57) And serving modules from your node_modules is a bad practice, so you should import the viewer with |
Thanks for the quick answer, I wanted to clarify if it is possible to access the bracketsViewer variable in a specific component? I need something like this:
import { bracketsViewer } from "brackets-viewer"
export class Component implements OnInit {
async getData() {
const manager = new BracketsManager(storage);
const example = {
name: 'Example',
tournamentId: 1,
type: 'double_elimination',
seeding: ['Team 1', 'Team 2', 'Team 3', 'Team 4', 'Team 5', 'Team 6', 'Team 7', 'Team 8'],
settings: { seedOrdering: ['natural'] },
};
await manager.create(example);
const stage = await storage.select('stage', 0);
console.log(stage);
}
ngOnInit() {
this.getData();
}
} And how to display in component-tree.html? |
You don't need to import Add this in your index.html : <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/brackets-viewer/dist/brackets-viewer.min.css" />
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brackets-viewer/dist/brackets-viewer.min.js"></script> The library will define a global variable in the window object. So if you prefer, you can access it with |
After that, adding an empty div in your component-tree.html should do the job: <div class="bracket-viewer"></div> |
Thanks again for the quick answer, the tree is displayed. |
Hi, do you still have the code for angular? Can you show how did you call the lib in ts file, thanks in advance |
Ping @YouNone |
Hi @Drarig29; I am trying to implement in angular project. Although i have a html element with class name 'brackets-viewer', I am getting this error: It says 'Root not found'. Can you please help me. Thanks in advance |
Which version of the viewer do you use? |
In your screenshot, brackets-viewer.js/src/main.ts Line 85 in 4c9c685
So you might have a brackets-viewer.js/demo/with-api.html Line 62 in 4c9c685
And this parameter overrides the default |
I installed three packages:
But after this operation I could not find a detailed example of the installation. I was able to run the example with db.json and index html file, but that's all.
Therefore, I wanted to know if it can be run under angular and if so, how?
The text was updated successfully, but these errors were encountered: