So easy !!!

On Thursday, October 4, 2012 9:06:36 AM UTC-6, Pete Bacon Darwin wrote:
>
> If you use = then you don't put {{}} curly braces in.  The whole attribute 
> is the expression.
>
> On 4 October 2012 15:29, Nick Tsitlakidis <[email protected]<javascript:>
> > wrote:
>
>> I have tried it but it throws an error in the console.
>>
>> Error: Syntax Error: Token 'displayCard' is unexpected, expecting [:] at 
>> column 3 of the expression [{{displayCard}}] starting at [displayCard}}]. 
>> at Error (<anonymous>)
>>
>> I've checked the documentation about the = binding and I can understand 
>> that I need to make changes on how the card-item declaration binds to the 
>> model. But that's all I can get. This paragraph  in the documentation is 
>> not too helpful :D
>>
>> Any ideas?
>>
>>
>> On Thursday, October 4, 2012 3:54:38 PM UTC+3, Peter Bacon Darwin wrote:
>>
>>> Sure try the = binding instead.
>>>
>>> On 4 October 2012 13:44, Nick Tsitlakidis <[email protected]> wrote:
>>>
>>>> Is there a workaround for this? I mean can I pass the whole object to 
>>>> the directive somehow?
>>>>
>>>>
>>>> On Thursday, October 4, 2012 9:17:02 AM UTC+3, Peter Bacon Darwin wrote:
>>>>
>>>>> The @ scope binding interpolates the item and returns a string not an 
>>>>> object.
>>>>>
>>>>> Pete
>>>>> ...from my mobile.
>>>>> On Oct 4, 2012 2:11 AM, "Nick Tsitlakidis" <[email protected]> 
>>>>> wrote:
>>>>>
>>>>>>  Hello to all.
>>>>>>
>>>>>> I'm having trouble understanding a problem that came up today as I 
>>>>>> was working with directives.
>>>>>> I've created a cardItem directive which contains some pretty basic 
>>>>>> controls. To be more specific, some buttons.
>>>>>> The following code demonstates how I did it.
>>>>>>
>>>>>> angular.module('SoloGame.directives',[])
>>>>>>     .directive('cardItem', function()
>>>>>>     {
>>>>>>         return {
>>>>>>             restrict:"E",
>>>>>>             scope:{card:'@'},
>>>>>>             templateUrl: './components/CardItem.html',
>>>>>>             compile:function(tElement,tAttrs)
>>>>>>             {
>>>>>>                 return function(scope,element,attrs)
>>>>>>                 {
>>>>>>                     scope.handleSelection = function(selectedItem)
>>>>>>                     {
>>>>>>                           //do something here
>>>>>>                     }
>>>>>>                 }
>>>>>>             }
>>>>>>         };
>>>>>>     }
>>>>>>
>>>>>> )
>>>>>>
>>>>>> The buttons included in the CardItem.html are defined this way : 
>>>>>> <button ng-click="handleSelection('field1')"></button>
>>>>>>
>>>>>> So I use the new element in the following way <card-item 
>>>>>> card={{displayCard}}></card-item>
>>>>>>
>>>>>> The displayCard is included in a model and its updated through a json 
>>>>>> service call.
>>>>>>
>>>>>> What I want to do after that, is having the button inside the item 
>>>>>> being bound to a specific property of the displayCard object.
>>>>>>
>>>>>> If I use it as a complete object the binding works (<button 
>>>>>> ng-click="handleSelection('field1')">{{card}}</button>)
>>>>>> But if I try to access a specific property it doesn't. (<button 
>>>>>> ng-click="handleSelection('field1')">{{card.id}}</button>)
>>>>>>
>>>>>> I guess I'm missing something crucial here so apologies if this has 
>>>>>> been asked a million times before.
>>>>>>
>>>>>> Thanks in advance,
>>>>>> Nick
>>>>>>
>>>>>> -- 
>>>>>> You received this message because you are subscribed to the Google 
>>>>>> Groups "AngularJS" group.
>>>>>> To post to this group, send email to [email protected].
>>>>>> To unsubscribe from this group, send email to angular+u...@
>>>>>> googlegroups.com.
>>>>>>
>>>>>> Visit this group at http://groups.google.com/group/angular?hl=en.
>>>>>>  
>>>>>>  
>>>>>>
>>>>>  -- 
>>>> You received this message because you are subscribed to the Google 
>>>> Groups "AngularJS" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to angular+u...@
>>>> googlegroups.com.
>>>> Visit this group at http://groups.google.com/group/angular?hl=en.
>>>>  
>>>>  
>>>>
>>>
>>>  -- 
>> You received this message because you are subscribed to the Google Groups 
>> "AngularJS" group.
>> To post to this group, send email to [email protected]<javascript:>
>> .
>> To unsubscribe from this group, send email to 
>> [email protected] <javascript:>.
>> Visit this group at http://groups.google.com/group/angular?hl=en.
>>  
>>  
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to