2

I'm writing a single page web application using AngularJS framework with angular-ui extension.

I want to create my own look and feel for all kind of GUI components like DropdownList, DatePicker and other custom components.

When should I write custom directives and when should I use HTML tags like div, and span whith css classes (borders, background, additional buttons when hovering and more) in order to accomplish that?

Is it better or worse to create custom directives or html tags with classes?

What do you think?

Thanks

3
  • You don't need angular (or any framework) to style an application.
    – lucuma
    Commented May 11, 2014 at 14:22
  • @lucuma - I'm asking whether to use angular directive to create custom GUI component, meaning the directive's template will include divs and styles and act as stand alone component against doing it as part of my DOM using styles only (without any directive)
    – xhuur
    Commented May 11, 2014 at 17:27
  • Your question is whether it is better to create directives or html tags with classes. If you can accomplish it with an html tag and a class it makes little sense to use a custom directive.
    – lucuma
    Commented May 12, 2014 at 13:56

1 Answer 1

1

Directives are used for DOM manipulation - if you can achieve what you want with only a class, then do it. If you need to use different HTML elements / alter the functionality of the elements, apply a directive.

2
  • Can you bring your own use-case for that? when did you use css styling and when your own directive?
    – xhuur
    Commented May 11, 2014 at 14:07
  • @xhuur -- Best example I can think of that I recently used - we wanted multiple select to behave natively on mobile, and custom checkbox dropdown on desktop / laptop - wrote a directive that when applied checked for mobile and applied the correct HTML based on that. Classes would be used if we only wanted to style the select a certain way, but we had to alter the functionality.
    – tymeJV
    Commented May 11, 2014 at 15:13

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.