M4N
M4N

Reputation: 96606

Different ways to define UI elements in ionic

When using ionic framework for building apps, there are two ways how UI elements can be defined:

using div tags:

<div class="bar bar-header bar-positive">
  ...
</div>

using directives:

<ion-header-bar class="bar-positive">
  ...
</ion-header-bar>

In the documentation, the first variant (using div) is used. But in a course I was watching, the second one was used (and it seemed cleaner to me).

What are the differences between the two ways shown above? Is there a preferred or recommended way of defining UI elements?

Upvotes: 0

Views: 35

Answers (2)

Aniket Bhange
Aniket Bhange

Reputation: 55

ion-header-bar tag is just Directive written by ionic with some fantastic attribute which you will not get in div tag

attribute like :

align-title

no-tap-scroll

this both comes with ion-header-bar tag so if you want to perform any action on the view so u can use ion tag or only for view purpose you can use div tag.

Upvotes: 1

R&#233;mi P
R&#233;mi P

Reputation: 440

I recommend you to use Directives instead of Div if you need to access to corresponding APIs. For example for a list : http://ionicframework.com/docs/api/directive/ionList/ Using the directive will allow you to use APIs options.

BUT, if you just want a beautiful UI, and you don't need APIs, you can use div which will render templates fastly.

Upvotes: 1

Related Questions