Question

I have a scope variable (myVar) which is defined in MyController:

angular.module('myApp.controllers').controller('MyController', ['$scope', function($scope) {
    $scope.myVar = 'whatsoever';
}]);

I want to use its value within my template but I keep getting this error: Unknown tag 'myVar'. I think I need to escape myVar somehow:

<section ng-controller="MyController">
    <span class="{{myVar}}">{{myVar}}</span>
</section>

Thanks in advance :)

Was it helpful?

Solution

According to the documentation for kiwi templates at https://github.com/coolony/kiwi, the only mechanism that they provide for escaping out of their template mode is the {{raw}} {{/raw}} clause. so you would probably accomplish what you want by doing the following:

{{raw}}<span class="{{myVar}}">{{myVar}}</span>{{/raw}}

That being said, I don't suspect this is a very good engine to use for templates with Angular.js compatibility, as the mixing of the use of the {{ }} operand between the two frameworks will make troubleshooting issues extremely laborious.

OTHER TIPS

You have not injected $scope into your controller. Also use $scope instead of scope. Like this...

angular.module('myApp.controllers', []).
  controller('ImagesCtrl', ['$scope', '$http', function ($scope, $http) {
        $scope.didSelectLanguage=function($scope, $http) {
            console.log($scope);
            $http.jsonp('http://localhost:3000/image?quantity=1&language='+this.language+'&Flag=&callback=JSON_CALLBACK')
            .success(function(data){
            $scope.image = data;
            });

        }

  }])
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top