私のHTMLは引数をディレクティブ関数に角度で渡すにはどうすればよいですか?
<ul id="suggestions" class="suggestions-list"><li
ng-repeat="suggestion in suggestions track by $index"
class="suggestion-item"
ng-click="toggleSkill(suggestion, 'here')"
ng-class="{active : selectedIndex === $index}"
><span class="small clr-secondary">{{suggestion}} - {{$index}}</span></li></ul>
され、ディレクティブで、私が持っている:
link: function(scope, elem, attrs) {
scope.toggleSkill = function(item, index) {
debugger
SkillsService.searchResults = []
if (scope.selectedTags.indexOf(scope.suggestions[index]) === -1) {
scope.selectedTags.push(scope.suggestions[index])
scope.searchText = ""
何らかの理由で
、index
機能はundefined
として入ってきますで。それはなぜでしょうか?
本当に奇妙な提案は正しく渡されますか?あなたの関数の中で 'console.log(arguments);'を試してみると、どこかのパラメータ 'ここ'が見えますか? – quirimmo
'suggestion'が正しく渡されます – Shamoon