Home Can't call function inside custom directive. Scope is not what I want to use

# Can't call function inside custom directive. Scope is not what I want to use

user3801
1#
user3801 Published in March 19, 2018, 4:37 pm
 I used to have this inside my html 'calculations-td-plan.html' 
{{foodCalculation.food.name}} {{foodCalculation.gram_amount}} g {{foodCalculation.kcal}} kcal {{foodCalculation.proteina}} g {{foodCalculation.cho}} g {{foodCalculation.lipideos}} g
 Then I create a directive like above. 
Opção {{ option }}
Alimento
{{foodCalculation.food.name}}
 And I call this diretive inside 'calculations-td-plan.html' as 
 And this is my directive JS. 'use strict'; angular.module('nutriApp').directive('mealOption', ['$compile', function($compile) { var mealOption = { restrict: 'E', templateUrl: 'views/checkins/meal-options.html', require: 'foodSelector', scope: { option: "@", items: "=", selectedmealcalc: "=" } }; mealOption.controller = ['$scope', 'Food', function($scope, Food) { $scope.sumFood = {};$scope.summerizeOption = function(foods) { if(foods.length > 0){ \$scope.sumFood = Food.summerize(foods); } }; }]; return mealOption; }]);  But now the funcions that I am calling edtiFoodCalc and removeFoodCalc are not working. When I put ng-controller in my directive it works, (Only call the method) but I can't get the same scope. 
 I am trying to edit with edtiFoodCalc and I am not getting the result that I want. I think ng-controller creates new scopes when I do ng-repeat, and when I did not have a directive the code worked. 

 You need to login account before you can post.
Processed in 0.590237 second(s) , Gzip On .