角度误差ng-if

时间:2014-11-07 02:29:54

标签: javascript html angularjs accordion angular-ng-if

Angular Js给我这个错误链接

 [1]http://errors.angularjs.org/1.2.10/$parse/lexerr?p0=Unterminated%20quote&p1=s%2013-14%20%5B'%5D&p2=recipe.ID%20!%3D%3D'

我不知道如何应用解决方案。请帮我。 谢谢 我的javascript:

var app = angular.module('sample', [])

app.directive("otcDynamic", function ($compile) {// compile Json data return and wrap inside html
    return {
    link: function (scope, element) {
        var template = global.userhtml;
        var linkFn = $compile(template);
        var content = linkFn(scope);
        element.append(content);
     }
   }
});

Json Data from web api

var global {
userhtml ='<table class="recipe-table" cellspacing="0" cellpadding="0"><tbody><tr class="recipe-list" data-ng-repeat="recipe in recipe_data" ng-if="recipe.Keyword == keyw.Keyword" ><td  id="td-img{{recipe.CodeListe}}" rowspan="2"><center><span id="img{{recipe.ID}}X"><a id="{{recipe.ID}}" href="javascript:void(0);"> <img  ng-if="recipe.ID !==''" fallback-src="images/default.png" ng-src="{{recipe.Pictures}}" class="images" id="img{{recipe.ID}}"/><img  ng-if="recipe.Pictures===''" class="images" src="images/default.png" id="img1"/></a></span></center></td><td class="recipes"><div id="drn" class="div-recipe-name"><strong>{{recipe.Name}}</strong></div><br /><div id="drd" class="div-recipe-desc">{{recipe.desc}}</div><div class="div-recipe-allergen">{{recipe.allergen}}</div><div class="div-recipe-cost">{{recipe.cost}}</div></td></tr></tbody></table>' 
}

我的Html:

  <accordion close-others="false">
  <div>
    <accordion-group class="div-recipe-header">
      <accordion-heading></accordion-heading>
        <my-directive></my-directive>
          <div otc-dynamic></div>   
    </accordion-group>
  </div>
</accordion>

1 个答案:

答案 0 :(得分:0)

您的网络API应该返回以下内容:

global

但请注意,您还有其他方式(更好的方法)来做到这一点。您可以接收纯json数据并使用html模板进行渲染。

还有一件事:git status On branch dev Your branch is ahead of 'master' by 2 commits. 是许多语言和框架中的保留字,并且它不是变量或散列键的好名称。考虑将其更改为更合适的内容。