简体   繁体   中英

ng-click not working within bootstrapped ng-include

i've an ng-include bootstrapped actually

<a data-href="#/speakers/{{speaker.id}}" ng-click="myFunc('{{speaker.id}}')">
    <span class="speaker-name">{{speaker.name}}</span>
    <span class="speaker-title-company">{{speaker.title}}, {{speaker.company}}</span>
</a>

ng-include is

<ng-include id="speakers" data-ng-controller="SpeakerController" src="'js/view/partials/speakers.html'" ng-show="toggle"></ng-include>

boostrapping

var self = this;

angular.module(this.constructor.NAME, [])
.controller("SpeakerController", function($scope, $location){self.speakerController($scope, $location)})
angular.bootstrap(document.getElementById("speakers"), [this.constructor.NAME]);

and then the speakerController

speakerController: function($scope, $location) {
    var self = this;

    $scope.myFunc = function(param){console.log('in');self.myFunc(param)}
},

myFunc: function(param) {
    console.log(param);  
},

Change to ng-click="myFunc(speaker.id)" . You don't need to use an expression there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM