忽略从控制器传递到组件的字符串化JSON对象中的撇号

时间:2017-11-03 21:40:53

标签: javascript angularjs angular-components apostrophe

我正在渲染一个从父控制器以这种方式传递数据的组件。但是,我收到一个错误,因为撇号被读作最终引用(即

//Sample Object
var data = { "name": "Shelly O'brien", grade: 12}

 function template(data) {
      return $compile("<node componentdata='" + angular.toJson(data) + "'>
      </node>")($scope);
    }

0 个答案:

没有答案