ElkArte Community

Elk Development => Theme development => Topic started by: meetdilip on August 12, 2016, 08:07:55 pm

Title: Add Angular to PHP Template
Post by: meetdilip on August 12, 2016, 08:07:55 pm
I want to add this piece of AngularJS code into home page. Can someone tell me how

Code: [Select]
<input type="color" ng-model="vm.bgcolor">
    <div  ng-style="{'background-color':vm.bgcolor}">
      Sample area <br>
      {{vm.bgcolor | json:true}} <br>
    </div>

Title: Re: Add Angular to PHP Template
Post by: ahrasis on August 12, 2016, 08:36:07 pm
I am not so sure about that code but unless  AngularJS is included in ElkArte, you should call it first before putting that code in.
Title: Re: Add Angular to PHP Template
Post by: meetdilip on August 12, 2016, 08:41:32 pm
I did add Angular to index.template.php . Consider it as adding HTML to a template. Nothing different.
Title: Re: Add Angular to PHP Template
Post by: emanuele on August 13, 2016, 03:45:34 am
I'll give you two example of addons I wrote using angular:
https://github.com/emanuele45/MessageHistory
https://github.com/emanuele45/PmNotification
Title: Re: Add Angular to PHP Template
Post by: meetdilip on August 13, 2016, 05:24:53 am
@emanuele , thanks. A little prompting too would be great.
Title: Re: Add Angular to PHP Template
Post by: emanuele on August 13, 2016, 07:43:03 am
https://www.codeschool.com/courses/shaping-up-with-angular-js <= anything I know about Angular comes from this course.

The addons should be quite self-explanatory: the template is in template files, the js is in js files, the whole adding is done via hooks and using template layer, for example:
https://github.com/emanuele45/MessageHistory/blob/master/MessageHistory.integrate.php#L23

Your question is rather generic: "where do I put some code?"
The only answer I can give you is: BoardIndex.template.php is the template of the home page.
If you can narrow down your question and make it a little more specific, it could be easier to pinpoint the answer you are seeking. ;)
Title: Re: Add Angular to PHP Template
Post by: meetdilip on August 13, 2016, 07:48:48 am
The above code adds a colour picker which affects the background. I would like to add it available to end users to change the theme's colour scheme.