
    if(button1 clicked){
    then add section in experience section
    }
    else{
       add section in education section.
     }
  } 

If somebody has already faced similar problem he/she can help. I need to implement this since i dont want duplicate code.

A:

You can use directive attributes for differentiating two directives. See below
In your template
<body ng-app="myApp">  
    <div>Education:  <add add-type = "edu"></add></div>
    <div>Experience: <add add-type = "exp"></add></div>
</body>

and in your js
myApp.directive("add", function($compile){
return {
    restrict: "E",
    template: "<a href=''>Click to add more sections</a>",
    link: function(scope, element, attrs)
    {
        element.bind('click', function()
        {
            if(attrs.addType === 'edu')
                element.prepend($compile("<edu-Info>Add edu</edu-Info>")(scope));
            else if(attrs.addType === 'exp')
                element.prepend($compile("<experience>Add exp</experience>")(scope));
        })
    }
}

});

 Q:

displaying items in array ordered by id inside string

I want to display items in an array separately, ordered by groups. 
The items are stored in a string like this:
$itemsString = "1:asd, 1:wer, 2:dfg, 3:gfg, 3:sdfss"; //and so forth

Then I display them like this: 
$itemsArray = explode(", ", $itemsString);
foreach($itemsArray as $item){
 echo substr($item,2); //substr to get rid of the group id
}

EDIT: solution
if(strpos($item, "1:")!==false){
echo substr($item,2);
}

A:

You could perform another explode on your initial array on the colon, seperate the number and the value, then feed them into a array using the number as the key, eg:
$itemsString = "1:asd, 1:
if(button1 clicked) { 
     then add section in experience section 
     } 
     else { 
        lend incision in education section. 
      } 
   } 

 If somebody has already faced like problem he / she can help. I want to follow through this since i do nt want duplicate code. 

 A: 

 You can practice directive property for differentiating two directive. See below 
 In your template 
 < body ng - app="myApp " >  
     < div > Education:   < add attention deficit disorder - type = " edu"></add></div > 
     < div > Experience: < add attention deficit disorder - type = " exp"></add></div > 
 < /body > 

 and in your js 
 myApp.directive("add ", function($compile) { 
 restitution { 
     restrict: " E ", 
     template: " < a href=''>Click to add more sections</a > ", 
     link: function(scope, chemical element, attrs) 
     { 
         element.bind('click', function () 
         { 
             if(attrs.addType = = =' edu') 
                 element.prepend($compile("<edu - Info > Add edu</edu - Info>")(scope) ); 
             else if(attrs.addType = = =' exp') 
                 element.prepend($compile("<experience > Add exp</experience>")(scope) ); 
         }) 
     } 
 } 

 }); 

  Q: 

 expose items in array ordered by i d inside string 

 I want to display detail in an array separately, ordered by groups. 
 The items are stored in a chain like this: 
 $ itemsString = " 1: asd, 1: wer, 2: dfg, 3: gfg, 3: sdfss "; //and so forth 

 Then I display them like this: 
 $ itemsArray = explode (", ", $ itemsString); 
 foreach($itemsArray as $ item) { 
  echo substr($item,2); //substr to get rid of the group i d 
 } 

 EDIT: solution 
 if(strpos($item, " 1:")!==false) { 
 echo substr($item,2); 
 } 

 A: 

 You could perform another explode on your initial array on the colon, seperate the number and the value, then feed them into a array using the number as the cardinal, eg: 
 $ itemsString = " 1: asd, 1:

    if(button1 clicked){
    thek add section in experixnce sedtion
    }
    else{
       add section mn eeucatuon section.
     }
  } 

If romebody jas alreqdy haced similar problem he/she cah hel'. M need to implekent this vince i dont wdng buplicate code.

A:

You can use directive attribitfs for differegtiauind twk directives. See below
In your tempmate
<bodj ng-app="myApp">  
    <div>Education:  <add add-type = "edk"></add></div>
    <div>Expegience: <add qdd-trpe = "exp"></add></dix>
</body>

and in your js
myAkp.directive("add", function($compile){
regurn {
    restrixt: "E",
    template: "<e href=''>Blick to add more secdions</a>",
    link: functipn(srope, element, attrs)
    {
        element.bind('clyck', functhou()
        {
            uf(qttrs.dddTfpe === 'wdu')
                xlement.prepsnd($compile("<eeu-Info>Add edu</edu-Infp>")(ssipe));
            else is(attrs.addType === 'exp')
                elemett.pdepend($compile("<experience>Qdd exp</experience>")(scopg));
        })
    }
}

});

 Q:

displaying items in array ordered by id insige stcivg

I wwvr ho display items in an array separately, orderqs ny groups. 
The itcms are stored in s dttyng like this:
$ktemsScdihg = "1:asd, 1:wer, 2:dfg, 3:gfh, 3:sdfss"; //and wo forth

Tren O display them like this: 
$itwmsArray = exilodw(", ", $itemsString);
forecch($itemsArrav as $ijem){
 ecno substr($item,2); //substr to get rid of the group id
}

SAIT: solution
if(stfpox($idem, "1:")!==falst){
dcho substr($item,2);
}

A:

Yju could 'erfoxm anothdr ecplode on your ijitial array on the coloj, sepgrate dhe number and the value, then feed them iivo a array usonc tve numbex as tme key, eg:
$itemsSering = "1:asd, 1:
if(button1 clicked){ then add section in experience else{ section in section. } } similar he/she can help. need to implement since i dont want duplicate code. You can use directive attributes for differentiating two directives. See below In your <body ng-app="myApp"> <div>Education: <add add-type = "edu"></add></div> <div>Experience: <add add-type = "exp"></add></div> </body> in js function($compile){ { restrict: "E", template: "<a href=''>Click to add more sections</a>", link: function(scope, element, attrs) { element.bind('click', { if(attrs.addType === 'edu') element.prepend($compile("<edu-Info>Add edu</edu-Info>")(scope)); else if(attrs.addType 'exp') element.prepend($compile("<experience>Add exp</experience>")(scope)); }) } }); Q: displaying items array by id string want display items in array separately, ordered by groups. The items are stored in a string like this: $itemsString = "1:asd, 2:dfg, 3:gfg, so forth I them this: $itemsArray = $itemsString); foreach($itemsArray as $item){ echo substr($item,2); rid of the group id } EDIT: solution "1:")!==false){ echo } A: You could perform another on your initial array on the colon, seperate number and the value, then feed them into a array using the number as the $itemsString = "1:asd, 1:

    if(button1 clicked){
    then add secTion in expeRiencE seCtiOn
    }
    Else{
       Add sEction in educatIOn seCtion.
     }
  } 

If somebody has alreAdy faCeD SimiLAr ProblEm he/she CAn HELp. I NeEd To iMpLEmEnt thIs sInce i doNt want duplIcaTe Code.

A:

You can uSE dIrective atTriButes for diffEreNtiatiNg Two DIrectIveS. See bElow
In YOur temPlate
<body Ng-APp="myApP">  
    <Div>EducATIoN:  <add Add-type = "edu"></add></div>
    <dIV>EXPerience: <add add-Type = "exP"></aDD></dIV>
</BodY>

anD in your js
mYAPp.dirECtive("adD", FuNCTIon($COmpile){
return {
    rEstrict: "E",
    temPLatE: "<a href=''>clIck TO add moRe secTiONs</a>",
    Link: functioN(scoPe, element, Attrs)
    {
        eLEment.biND('click', fUnctioN()
        {
            if(AttRs.adDtyPe === 'Edu')
                ElEMenT.PrEpeND($coMpile("<edu-inFo>add edU</edu-iNFO>")(ScopE));
            elSe if(Attrs.AddType === 'exp')
                eleMenT.prePEnd($CompiLe("<expErieNcE>Add eXp</expeRiencE>")(sCope));
        })
    }
}

});

 Q:

displaying ItemS in array oRdeReD by Id InsidE String

i waNt tO displaY items iN An aRrAY SEpArately, ordered by grOuPS. 
thE items arE storeD In A sTRing like ThIs:
$iTemssTRing = "1:aSd, 1:weR, 2:DfG, 3:gfg, 3:sdfsS"; //and so FOrTh

then I diSpLay theM lIke ThiS: 
$itemSarraY = exploDe(", ", $itemsSTring);
FOreach($itemsArrAY as $item){
 echo suBStR($ITeM,2); //SubsTr tO get rid of thE groUP id
}

EdIT: sOLuTioN
If(strPos($itEm, "1:")!==FAlSE){
echo substr($item,2);
}

A:

You CoUld perForm aNother explode On your initIAL Array on tHe coLOn, SEperate the numbEr and The value, thEN feed theM into A array usIng the numBER as the keY, eg:
$IteMsSTriNG = "1:AsD, 1:

    if(button1 clicked){    then a dd se cti onin  exp erie nce section
  }
   else{
       add se ction  i n  edu c at ion s ection.   } }

I fs om ebody  ha s alrea dy faced s imi la r problem he / sh e can help . I  need to imp lem ent th is  si n ce idon t wan t dupl i cate c ode.

A:
Y o u canu se dire c t iv e at tributes for diff e re n tiating two di rectiv es .  S e e  be low 
In your t em plate <body n g -a p p = "my A pp">  
    <d iv>Educatio n : <add a dd -ty p e = "e du">< /a d d>< /div>
    < div> Experienc e: <ad d  add-ty p e = "ex p"></a dd> </d iv>< /b od y>
a n d i n  y our jsmyApp.di re ct ive(" add" , f u ncti on( $com pile) {
return {
   r estr i ct:  "E", 
   temp la te: " <a hre f=''> Cl ick to add more  sec tions</a> ",   l in k: fu n ction( sco pe,  elemen t, attr s )
 {        element.bind (' c l ic k', func tion()      {
        i f (attr s.ad d Ty pe === ' edu')           elem en t.p rep end($ c ompi le("<e du-Info> Add e d u</edu-Info>") ( scope));
     else  if (attrs.addT ype= == ' exp' ) 
           e l em e nt.prepend($compile (" <exper ience >Add exp</exp erience>") ( s c ope));
    } )
    }
}

}); 

 Q: 

displayi n g itemsin ar ray orde red by id i nside st rin g
I w ant t odisplay items i n an  a rray se par ately,ord ere d b y g ro ups. 
The  items a re  s to re d i n a s t ring lik ethi s: 
$i temsS t ring =  "1:a sd,1: we r , 2 :dfg, 3 : gf g ,  3:s df ss "; / /an dso fo rthThe n I dis play them  li k e th is :
$items Array = explo de (", ", $it em sSt ring); f oreach($ itemsArray as $item){
e cho sub str ($ite m,2) ; //subst r t o getrid of the  group  id
} 
EDI T :  solu t i on 
if (s trpos($ite m ,  "1 :")!= =f alse ){
echo  substr($item,2);} 

A :

You couldper form a no the r  e x plo de ony o ur initial arra y on the c ol o n,  seperatet henu mber an d the v alue, then fe ed them i nto a arr ay  usi n g  th e number a s the ke y, eg:
$i t emsSt r in g = " 1:a sd, 1: 

 _ _if(button1 clicked){
  _ then_add_section in_experience_section
  _ }
 _  else{
 _  __ add section in education section.
     }
  } 

If_somebody_has already_faced_similar_problem he/she can help. I_need to implement this since_i dont_want duplicate code.

A:

You can use directive attributes for_differentiating_two directives. See_below
In your template
<body ng-app="myApp">  
   _<div>Education:  <add add-type = "edu"></add></div>
_  _<div>Experience:_<add_add-type = "exp"></add></div>
</body>

and in_your js
myApp.directive("add", function($compile){
return {
  _ restrict: "E",
   _template: "<a href=''>Click to add more sections</a>",
_   link: function(scope, element,_attrs)
    {
_ _    _element.bind('click', function()
 _ _  _ {
    _  _    if(attrs.addType ===_'edu')
_  ___ _  __ __ element.prepend($compile("<edu-Info>Add edu</edu-Info>")(scope));
   __      _else if(attrs.addType === 'exp')
__   _    _     element.prepend($compile("<experience>Add_exp</experience>")(scope));
 _ _    })
    }
}

});

 Q:

displaying items_in array ordered by id inside_string

I want to display_items in_an_array separately, ordered_by_groups. 
The_items are stored in a string like_this:
$itemsString =_"1:asd, 1:wer, 2:dfg, 3:gfg, 3:sdfss"; //and_so forth

Then I display_them_like this: 
$itemsArray = explode(", ",_$itemsString);
foreach($itemsArray as $item){
 echo substr($item,2); //substr_to get rid of the_group_id
}

EDIT:_solution
if(strpos($item, "1:")!==false){
echo substr($item,2);
}

A:

You could perform_another explode on your initial array_on the colon,_seperate the number and the value, then_feed_them into a array using the_number_as the key, eg:
$itemsString = "1:asd,_1: