1

I want declare directive in DOM and set scope properties like a Local scope property and can't do it...

If I have property type int, its fine but if dateType is string or datetime I have troubles...

This is my html declare:

<div ng-controller="MyCtrl">
    <time-reminding relative-days-to-finish="10" reminder-name="Robo"></time-reminding>
</div>

and here is directive:

myApp.directive('timeReminding', function() {
    return {
        template: "<div>foo - {{relativeDaysToFinish}}<br />{{reminderName}}</div>",
        scope: {
            relativeDaysToFinish: '=',
            reminderName: '='
        },
        replace: true,
        restrict: "E",
        constroller: function($scope){

        }
    }
});

What am I doing wrong?

Here is jsFiddle

Thanks!

David Slavík
  • 1,132
  • 1
  • 14
  • 23

1 Answers1

1

Use it like this: reminder-name="foo" or this: reminder-name="'Robo'" for two-way binding (=) . Fiddle: http://jsfiddle.net/rj3Rr/9/

And like this:

 reminder-name="{{foo}}" 

for a one-way (@) , http://jsfiddle.net/rj3Rr/6/

Great Mark Rajcok's explanation: What is the difference between '@' and '=' in directive scope in AngularJS?

Community
  • 1
  • 1
Ivan Chernykh
  • 41,617
  • 13
  • 134
  • 146
  • And why it stops working when I use "@" instead of "=" in scope declaration? – David Slavík Sep 30 '13 at 11:25
  • 1
    @DavidSlavík Have a look at Mark Rajcok's explanations and related links that he gives: http://stackoverflow.com/questions/14050195/what-is-the-difference-between-and-in-directive-scope/14063373#14063373 – Ivan Chernykh Sep 30 '13 at 11:33