Hi, 

The reason you didn't get an error with 

parent:"^parent"

Is that JavaScript allows the dynamic creation of properties on an object, 
and in your case, you just created one with the name: parent.  This isn't 
an error by - and angular just went and checked for a 'require' property 
and didn't find one (since it optional, this is a valid scenario).

In terms of the 'right' way to do this, a simple solution is this plnkr 
<http://plnkr.co/edit/O0fIgV?p=preview>.  Here, the child directive shares 
the scope with the parent and so the property (show) is visible from the 
child. You may however want to

   - Introduce a dot in the model (i.e. $scope.model.show = true).  This 
angular 
   wiki page 
   <https://github.com/angular/angular.js/wiki/Understanding-Scopes> will 
   provide some understanding.
   - Introduce isolate scope in your directive (depending on your usage). 

Regards
Justin


On Sunday, October 12, 2014 3:06:53 PM UTC+2, César Costa wrote:
>
> Hi, i updated my plunk again and this is my solution:
>
> http://plnkr.co/edit/tVBYIE?p=preview
>
> Is it the correct solution for this problem?
>
> Thanks :)
>
> 2014-10-12 9:56 GMT-03:00 César Barone <[email protected] <javascript:>>
> :
>
>> Oh god. :p. Thanks Justin.
>>
>> Why angular doesn't show any error?
>>
>> I replaced and  i can't toggle child-two. I updated my plunk:
>>
>> http://plnkr.co/edit/tVBYIE?p=preview
>>
>>
>>
>> 2014-10-12 7:56 GMT-03:00 Justin Walsh <[email protected] 
>> <javascript:>>:
>>
>> Hi César
>>>
>>> In your child directives, replace:
>>>
>>>     parent: '^parent',
>>>
>>> with:
>>>
>>>     require: '^parent',
>>>
>>> Regards
>>> Justin
>>>
>>>
>>>
>>> On Saturday, October 11, 2014 8:56:11 PM UTC+2, César Costa wrote:
>>>>
>>>> Hi,
>>>>
>>>> I implemented a parent directive that have two child directives. When 
>>>> the user click in button inside child-one directive i need to toggle a 
>>>> content from child-two directive. But, the parent controller inject on 
>>>> childs directive are undefined. 
>>>>
>>>> This plunker show my case:
>>>>
>>>> http://plnkr.co/edit/tVBYIE?p=preview
>>>>
>>>> Can anyone help me?
>>>>
>>>>
>>>>  -- 
>>> You received this message because you are subscribed to a topic in the 
>>> Google Groups "AngularJS" group.
>>> To unsubscribe from this topic, visit 
>>> https://groups.google.com/d/topic/angular/UIyBJJSQjGs/unsubscribe.
>>> To unsubscribe from this group and all its topics, send an email to 
>>> [email protected] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> Visit this group at http://groups.google.com/group/angular.
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>

-- 
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