0

I have a block of HTML code as my template in my app.component.html file. This code refused to render on the browser. But when I replace the entire content of that file with shorter lines of code, the browser displays that. By shorter lines of code, I mean something like
<h1>Hello there</h1> <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s,</p>.

Below is my code: app.component.html

<div class="locator">
  <div class="container">
    <div class="row">
      <div class="col-md-12">
        <header class="inner-page-header landing-page-header">
          <span>Welcome to</span>
          <h1 class="start">Food</h1>
          <p>Daily new menus of breakfast, lunch, evening snacks and dinner; prepared by expert chefs.</p>
          <p>
          </p>
        </header>
        <div class="holder landing-page-form">
          <form accept-charset="UTF-8" action="/localities/set_locality"
                class="location-form col-xs-12 col-sm-6 col-sm-offset-3" data-remote="true" id="zip_form"
                method="get">
            <div style="display:none">
              <input name="utf8" type="hidden" value="✓">
            </div>
            <p>SELECT LOCATION </p>
            <hr class="small-line">
            <div id="locationField">
              <input class="form-control" id="autocomplete" placeholder="Enter your address"
                     onFocus="geolocate()" type="text"></input>
            </div>
            <div class=" text-center">
              <button id="singlebutton" name="findfood" class="btn btn-lg btn-space btn-primary">Find food</button>
            </div>
          </form>
        </div>
      </div>
    </div>
  </div>
</div>

app.component.ts:

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {

}

index.html:

......
  <div class="page-content">

    <app-root>Loading...</app-root>

  </div>
.......

All I see as output is: Loading

What am I missing?

2
  • Your app is not loading. The cause is impossible to diagnose without more info. Check the browser console for error messages and edit them into your post. Commented Dec 20, 2016 at 12:33
  • data-remote="true" and onFocus="geolocate()" can give errors. check console logs Commented Dec 20, 2016 at 12:42

2 Answers 2

1
<input class="form-control" id="autocomplete" placeholder="Enter your address"
                 onFocus="geolocate()" type="text"></input> <!-- error here --> 

Remove </input>

After that it renders, at least for me.

EDIT. Check the dev tools in browser, it tells where the error is! enter image description here

Sign up to request clarification or add additional context in comments.

2 Comments

@calistus Great! Well, check my post again, added picture. Check the dev tools in browser, it shows errors. So here the error is pointed out. Makes your life so much easier! :)
@calistus No problem, glad I could help! :) Please accept answer, so that no other people need to look at this question since it's solved! :)
0

you missed to define the function in class. Define geolocate method in class. it should fix your problem

import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css'],
})
export class AppComponent {
    geolocate() {
    }
}

2 Comments

I have that defined in an external JS file and I called this file in my index.html
you need to utilize that function here.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.