The ion-col with col-3 is causing a template parse error

Currently, I am facing an issue while trying to print data from a constructor. Everything is working fine until I added col-3 to ion-col. It seems like I missed including some module, but I am not sure which one.

This is my home.ts file:

import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {
  dni: any;
  constructor(public navCtrl: NavController) {
    this.dni = {
      // Data here
    }
  }

}


<ion-header>
  <ion-navbar>
    <ion-title>Home</ion-title>
  </ion-navbar>
</ion-header>

<ion-content padding>
  <ion-grid *ngIf="dni">
    <ion-row>
      <ion-col col-3>
        // Content goes here
      </ion-col>
    </ion-row>
  </ion-grid>
</ion-content>

This is the portion of my app.module.ts where the error occurs:

import { NgModule, ErrorHandler } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { IonicApp, IonicModule, IonicErrorHandler } from 'ionic-angular';
import { MyApp } from './app.component';

import { HomePage } from '../pages/home/home';
import { TabsPage } from '../pages/tabs/tabs';

import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';

@NgModule({
  // Module details here
})
export class AppModule {}

The specific error message I encounter is:

Error: Template parse errors: Unexpected character "c" ("<ion-col col-3> Wtorek: </ion-col [ERROR ->]col-3>"): ng:///AppModule/HomePage.html@11:20
. This happens for every instance of col-3 that I add. Any suggestions on what might be causing this issue?

Answer №1

Make sure to delete the col-3 attribute from your closing ion-col

<ion-content padding>
  <ion-grid *ngIf="dni">
   <ion-row>
    <ion-col col-3>
      Wtorek:
    </ion-col>
    <ion-col col-3>
      Do:
    </ion-col>
    <ion-col col-3>
      {{dni.Wtorek.do.godzina}} {{dni.Wtorek.do.linia[0],dni.Wtorek.do.linia[1]}}
    </ion-col>
    <ion-col col-3>

    </ion-col>
    <ion-col col-3>

    </ion-col>
   </ion-row>
  </ion-grid>
</ion-content>

Answer №2

Another important tip, in addition to @ChesterLaborde's response, is to always ensure that your selector and templateUrl have matching names. For instance, if your home component includes files named home.html and home.ts, your code should be structured like this

@Component({
  selector: 'home',
  templateUrl: 'home.html'
})

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

MongoJS Node findOne query inaccurately returns empty result set

Utilizing MongoJS: https://github.com/mafintosh/mongojs Retrieves all data Returns an empty array</p> The database contains the data I am looking for. I've also tried searching using a different key (such as name). Why is it unable to locate ...

Execute the JS function during the first instance of window scrolling

Currently, I have implemented a typewriter effect on my website that triggers when the user scrolls to a specific section. However, I want this effect to occur only once. Unfortunately, every time the user scrolls again (in any direction), the function is ...

What are the steps to showcase images on a webpage using angularjs?

After successfully saving images in MongoDB using AngularJS and Java, I need to retrieve the saved image from the database and display it on an HTML page using AngularJS. Below is an example of how I can retrieve the image in my controller: @GET @Path("/ ...

What is the correct way to utilize JavaScript's clearTimeout function with arguments?

I came up with a simple function to mimic the movement of window blinds. It runs on a server that receives requests with a direction parameter determining whether the blind should move UP, DOWN, or STOP. The simulation works like this: upon receiving a re ...

Calendar: Display upcoming dates within the next week starting from the current week

Hey there! I have a calendar that includes next and previous buttons. When the user clicks on the next button, the schedule for the upcoming week will be displayed. However, if the user clicks again, nothing happens. My goal is to only show dates for the n ...

When you click on the Prev/Next arrow in the JS slider, the image suddenly

I've been struggling to find a solution for this issue. This is my first attempt at using JS as I am in the process of learning. It's very likely that I'm not fully grasping the answers from my searches - apologies for that. What I'm l ...

Obtain the filter criteria within the user interface of a Kendo grid

My Kendo grid looks like this: <kendo-grid [data]="gridData" [pageSize]="state.take" [skip]="state.skip" [sort]="state.sort" [filter]="state.filter" filterable="menu" (dataStateChange)="dataStateChange($event)" > In the ...

Using Laravel Blade Variables in JavaScript Code

Trying to access a variable within blade syntax has posed a challenge for me: success: function(resp) { console.log(resp) var MsgClass = 'alert-danger'; $("#overlay").hide(); ...

Printing a React component using a button causes formatting related to className to be lost, while printing it inline preserves the formatting

I've hit a roadblock in trying to figure out the React and printing issue for the past week and a half, and it feels like I'm going in circles. Despite finding some helpful solutions on Stack Overflow, none of them seem to work completely for me ...

Do you know the location of the .bowerrc file in an Angular app generated by Yeoman?

Currently, I am going through a tutorial (http://www.sitepoint.com/kickstart-your-angularjs-development-with-yeoman-grunt-and-bower/) that may be outdated. It mentions a .bowerrc file after running the command yo angular. However, when I tried to locate th ...

Filtering a list of data with Angular checkboxes

I've been exploring different options for implementing data filtering using checkboxes, but it all seems a bit too complex for something that I would expect Angular to handle easily. Feel free to check out http://plnkr.co/edit/Gog4qkLKxeH7x3EnBT0i T ...

How to optimize JSON responses Using PHP

I have a straightforward MVC model. During an Ajax request, I send data to be processed by PHP and retrieve database records in JSON format. Since the object can be quite large, I am looking for a way to compress/encrypt it on the server-side in PHP and de ...

Guide on replacing placeholders in a text with input fields and connecting them with v-model in Vue.js

I am currently working on creating an exam page that features fill in the gap type questions. These questions have placeholders where students need to insert the correct words or phrases. The questions are fetched via an ajax request and consist of simple ...

Can a file be imported into Node.js without the need for packaging?

Is there a way to have an entire file evaluated in node? For example, let's say I want to evaluate the angular.js source file. An example of what the code could look like is as follows: jsdom = require("jsdom").jsdom; document = jsdom("<html>& ...

Populate an empty value in a key-value pair by using the subsequent value

Replace an empty value in a key-value pair with the first value of the next key. myitems = { 'items1': [{first:true, second:false}, {first:true, second:true}], 'items2': [], //should be filled with {first:true, second:false} 'it ...

What is the best way to display tip boxes for content that is added dynamically?

One of the challenges with my web page is that dynamically added content does not display tipboxes, unlike items present since the page load. I utilize the tipbox tool available at http://code.google.com/p/jquery-tipbox/downloads/list. To illustrate the i ...

Searching for similar but not identical results using Knex.js

I am seeking a solution to retrieve similar posts without including the post itself. Here is my approach: export async function getSimilars(slug: string) { const excludeThis = await getBySlug(slug) const posts = await knex('posts') .whe ...

Tips for utilizing the track OrbitControls in three.js

Presently, there are two blocks visible within the space: const material1 = new THREE.MeshBasicMaterial({color: '#00ff00'}); const cube1 = new THREE.Mesh(geometry, material1); cube1.position.set(0, 0, 0); const material2 = new THREE.MeshBasicMat ...

Can you include conditional logic within a switch statement?

I've been using if, else if, and else statements in my code but recently switched to switch statements which have made things much simpler. Now I'm wondering if it's possible to add multiple conditions inside a switch statement, similar to i ...

Access denial encountered when attempting to submit upload in IE8 using JavaScript

When running the submit function on IE8, I am receiving an "access is denied" error (it works fine on Chrome and Firefox for IE versions above 8): var iframe = this._createIframe(id); var form = this._createForm(iframe, params); ... ... ...