# Can't call function

**URL:** <https://forum.ionicframework.com/t/cant-call-function/21959>\
**Category:** ionic-v1\
**Created:** [April 30, 2015, 1:12pm UTC](https://forum.ionicframework.com/t/cant-call-function/21959 "2015-04-30T13:12:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sioesi](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sioesi](https://forum.ionicframework.com/u/sioesi)\
**Post date:** [April 30, 2015, 1:12pm UTC](https://forum.ionicframework.com/t/cant-call-function/21959/1 "2015-04-30T13:12:04Z")

</div>

I’m putting together a ionicPopup and within your content, I need to make a call to a function. The problem is that not called me and read as undefined function. I leave my code.

```
$scope.verInfo = function(marker,marker){
$ionicPopup.show({
   title: 'Información View',
   subTitle: '',
   content: '<i class="'+marker.icono+' ver_view-1" id="icono_like" ng-cloak ng-click='+$scope.darLike(marker.id)+'><span>'+marker.like+'</span></i>',
   buttons: [
    { text: 'Salir',
            onTap: function(e){
              
            }
    },
     {
       text: 'Ver Detalle',
       type: 'button-positive',
       onTap: function(e) {
          $scope.verView(marker.id);
       }
     },
   ]
  })
}

```

It’s a bit messy because the content is pure html. but $ scope.darLike function is not working, is not declared when inspecting items within the popup.

---

<div class="post-metadata">

**Author:** ![seanhill](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/seanhill/32/105765_2.png) [@seanhill](https://forum.ionicframework.com/u/seanhill)\
**Post date:** [April 30, 2015, 6:23pm UTC](https://forum.ionicframework.com/t/cant-call-function/21959/2 "2015-04-30T18:23:08Z")

</div>

Try `ng-click='darLike(marker.id)'` instead.

---

<div class="post-metadata">

**Author:** ![sioesi](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sioesi](https://forum.ionicframework.com/u/sioesi)\
**Post date:** [April 30, 2015, 6:52pm UTC](https://forum.ionicframework.com/t/cant-call-function/21959/3 "2015-04-30T18:52:10Z")

</div>

Still not working …

That’s what you get :

```
<i class="icon ion-android-favorite-outline ver_view-1" id="icono_like" ng-click="undefined"><span>2</span></i>
```

---

<div class="post-metadata">

**Author:** ![brandyshea](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/brandyshea/32/148286_2.png) [@brandyshea](https://forum.ionicframework.com/u/brandyshea)\
**Post date:** [April 30, 2015, 7:13pm UTC](https://forum.ionicframework.com/t/cant-call-function/21959/4 "2015-04-30T19:13:05Z")

</div>

If the function is called `$scope.darLike` you need ng-click to have `darLike` as a string in the ng-click, but [marker.id](http://marker.id) needs to be taken from the javascript, so something like this:

```
ng-click="darLike(' + marker.id + ')"

```

and you need to pass scope to the popup

```
$ionicPopup.show({
    title: 'Información View',
    subTitle: '',
    content: contentHtml,
    scope: $scope,
    ...

```

Codepen example: [http://codepen.io/brandyshea/pen/NqqgMW?editors=101](http://codepen.io/brandyshea/pen/NqqgMW?editors=101)

---

<div class="post-metadata">

**Author:** ![sioesi](https://avatars.discourse-cdn.com/v4/letter/s/d07c76/32.png) [@sioesi](https://forum.ionicframework.com/u/sioesi)\
**Post date:** [April 30, 2015, 7:24pm UTC](https://forum.ionicframework.com/t/cant-call-function/21959/5 "2015-04-30T19:24:05Z")

</div>

😊 thank you! it works great for me!
