Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Directives #59

Closed
nakome opened this issue May 29, 2017 · 5 comments
Closed

Custom Directives #59

nakome opened this issue May 29, 2017 · 5 comments
Assignees
Milestone

Comments

@nakome
Copy link

nakome commented May 29, 2017

Hi, I have a question ,how to make custom directive is this posible?

Something like this:

Moon.directive('blue',(el) => {
  el.style.color = 'blue';
});

<p m-blue>{{title}}</p>
@kbrsh kbrsh added the question label May 29, 2017
@kbrsh
Copy link
Owner

kbrsh commented May 29, 2017

Yes, that is possible, refer to the docs

@kbrsh kbrsh closed this as completed May 29, 2017
@nakome
Copy link
Author

nakome commented May 29, 2017

Hi, Good day i try but i get an error

Uncaught TypeError: Cannot read property 'type' of undefined

The code:

// index.html
<div id="app">
	<p m-color="red">{{title}}</p>
</div>
// app.js
Moon.directive('color',(el,val) =>{
	console.log(el,val);
	return el.style.color = val;
});

const app = new Moon({
	el: '#app',
	data:{
		title: 'Hello World'
	}
})

@kbrsh
Copy link
Owner

kbrsh commented May 29, 2017

Ahh, thanks for reporting the error! It was an issue with the compiler not generating correct code. Next time, use the developer version of Moon for a helpful error message.

This will be fixed in v0.11.0.

@kbrsh kbrsh reopened this May 29, 2017
@kbrsh kbrsh added the bug label May 29, 2017
@kbrsh kbrsh self-assigned this May 29, 2017
@kbrsh kbrsh added this to the v0.11.0 milestone May 29, 2017
@kbrsh kbrsh closed this as completed in 6ba5200 May 29, 2017
@nakome
Copy link
Author

nakome commented May 29, 2017

OK, Awesome project bro 👍

@kbrsh
Copy link
Owner

kbrsh commented May 29, 2017

Thank you! 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants