The Semantic UI Tabs in Angular 4 only function properly once they have been clicked on

I have set up semantic UI tabs in my app.component.html as shown below:

<div class = "ui container">
  <h1>Header/h1>
  <hr>

  <div style = "background-color: rgb(194, 221, 240);" class="ui top attached tabular menu">
    <a style = "font-size: large;" class="item active" data-tab="dtQuestions">Questions</a>
    <a style = "font-size: large;" class="item" data-tab="dtAddNewQuestion">Add new question</a>
    <a style = "font-size: large;" class="right item" data-tab="dtUserProfile">User profile</a>
  </div>

  <div class="ui bottom attached tab segment active" data-tab="dtQuestions">
    <app-question-list [questions]="questions"></app-question-list>
  </div>

  <div class="ui bottom attached tab segment" data-tab="dtAddNewQuestion">
    <app-create-question (questionCreated)="onQuestionCreated($event)"></app-create-question>
  </div>

  <div class="ui bottom attached tab segment" data-tab="dtUserProfile">
    <app-user-profile></app-user-profile>
  </div>
</div>

After loading the page, the tabs do not display initially and appear empty. However, upon clicking on a specific tab, the content gradually starts to show as if it requires time to load. I would like the contents to be visible immediately after opening the page, especially on the initially active tab.

To initialize the tabs in app.component.ts, I used the following code snippet:

export class AppComponent implements OnInit {
 ngOnInit(): void {
    $('.menu .item').tab();
  }

  public onQuestionCreated(question: Question): void {
    this.questions.push(question);
  }
}

I have written the above code but am unable to resolve the issue. Any guidance on how to fix this problem would be greatly appreciated.

Answer №1

I'm new to Semantic UI, and I noticed that the class "right" is causing an issue in the "User Profile" section. Can you please try removing it from the code below?

<a style = "font-size: large;" class="item" data-tab="dtUserProfile">User profile</a>

After looking through the documentation, I realized that the correct class for the active tab should be like this:

<div class="ui bottom attached active tab segment" data-tab="dtQuestions">
    <app-question-list [questions]="questions"></app-question-list>
</div>  

Hopefully, one of these solutions solves the problem.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Angular toolbar permanently positioned at the top of the screen

My custom toolbar, along with other components, is present in the app I'm working on. In the app.component, the structure looks something like this: <app-toolbar> </app-toolbar> <main> <a [routerLink]="['/login/en&a ...

When using Angular and Express together, the session is not continuous as each new request generates a fresh session

Unique Question I have encountered an issue with passport.js while trying to implement authentication in my express application. When I use req.flash('message', 'message content') within a passport strategy, the flashed information see ...

Are there any potential performance implications to passing an anonymous function as a prop?

Is it true that both anonymous functions and normal functions are recreated on every render? Since components are functions, is it necessary to recreate all functions every time they are called? And does using a normal function offer any performance improv ...

Strange Node.js: I always avoid utilizing `require()`, yet encountered an unexpected error

For more information on this particular issue, please refer to this link It's quite puzzling as I haven't used the require() function in my code, yet I'm receiving an error telling me not to use it. How odd! The problematic code snippet i ...

Querying with Node SQLite fails to return a value

So, here's my little dilemma: I have 3 methods that need to access a database file (SQLite3). export function F_SetupDatabase(_logger: any): void export function Q_RunQuery(query: string, db: "session" | "global"): any export func ...

I encounter an issue while attempting to add Firebase to my Angular project

I am facing an issue while trying to install Firebase in my Angular project. The command I used for installation is: npm install firebase @angular/fire --save However, when running this command, I encountered the following error: npm ERR! Unexpected end ...

What is the best way to set up a reactive form in Angular using the ngOnInit lifecycle

I have been facing an issue while trying to set up my reactive form with an observable that I subscribed to. Within the form class template, I used the ngOnInit lifecycle hook to fetch the desired object, which is the product. The first code snippet repre ...

The (change) function is triggered when there is a modification in the parent object of ngModel within Angular 2

When the (change) function on element is triggered with the parent object of ngModel change in Angular 2, this is how I assigned the model: (change)="OnScheduleChange(confirmSchedule)" [(ngModel)]="AddMedMod.schedule.numberOfDaysOn" Now, whenever I make ...

Encountered an issue during the migration process from AngularJS to Angular: This particular constructor is not compatible with Angular's Dependency

For days, I've been struggling to figure out why my browser console is showing this error. Here's the full stack trace: Unhandled Promise rejection: NG0202: This constructor is not compatible with Angular Dependency Injection because its dependen ...

The Angular selector is unrecognized: double-check that it belongs to the current module if it is an Angular component

After creating a component, I attempted to utilize it in another component by specifying its selector in the display segment. <app-component1></app-component1> However, I encountered a compile error. Upon reviewing the imports in the modules, ...

The TypeScript inference feature is not functioning correctly

Consider the following definitions- I am confused why TypeScript fails to infer the types correctly. If you have a solution, please share! Important Notes: * Ensure that the "Strict Null Check" option is enabled. * The code includes c ...

The transparency of Angular Primeng sidebar sets it apart from the rest

I'm currently working on a project using Angular 7 and PrimeNg v7. I am trying to implement the PrimeNg sidebar module, but I am facing issues with the background being transparent and the shadow not appearing when the sidebar is open: Here is what I ...

Encountering a 500 error (Internal Server Error) while trying to connect API Laravel 5.4 with Angular 2

Every time I try to submit a form from an Angular form to my API built on Laravel, I encounter a 500 error (Internal Server Error) in the console. What could be causing this issue? Note: The backend API functions perfectly when tested with POSTMAN. This ...

Is it possible to capture user input using a rich text editor such as Quill and save the data as a .json file by sending a POST request?

My website features a sophisticated text editor known as ngx-quill, where users can input their content. I am currently working on a project that requires me to generate a JSON file containing user input and then submit this JSON file. I am seeking guidan ...

Creating an Angular service that checks if data is available in local storage before calling an API method can be achieved by implementing a

I am currently working on developing an Angular service that can seamlessly switch between making actual API calls and utilizing local storage within a single method invocation. component.ts this.userService.getAllUsers().subscribe(data => { conso ...

What is the method for adjusting the spacing between binding tags within HTML code formatting specifically for TypeScript elements in IntelliJ?

My Angular binding currently defaults to <h1>{{typeScriptVar}}</h1>, but I would like it to be set as <h1>{{ typeScriptVar }}</h1> when I use the format code shortcut in InteliJ. Can anyone assist me with this issue? I have resear ...

The addControl function inside a for loop and async function is not properly assigning a value to the form

My goal is to iterate through an array, make a HTTP request, retrieve another array from it, and assign the selected object from the fetched array to a newly added Form Control in the form. This is how I approached it: for (let i = 0; i < typeaheadFiel ...

Understanding type inference in TypeScript

I'm attempting to grasp the concept of inferring generics in Typescript, but I can't seem to figure out where I'm going wrong. Although my concrete example is too large to include here, I've provided a link to a small TypeScript playgro ...

Challenge with Bootstrap 4 post-transfer to Angular rc5 from rc beta

I recently upgraded my angular application from Beta version to Angular rc5. However, I encountered errors when attempting to add any bootstrap control in a component. (index):48 Error: (SystemJS) No Directive annotation found on Dropdown(…)(anonymo ...

Determine whether a many-to-many relationship involves a specific entity

I am currently working on developing an API for managing surveys. One challenge I'm facing is determining whether a specific user has moderation privileges for a particular survey. A many-to-many relationship has been set up between the two entities. ...