2013-11-26 38 views

回答

6

您将为每个形状创建一个指令包装。这里有一个粗略的例子,

module.directive('morrisLine', function(){ 
    return { 
    restrict: 'EA', 
    template: '<div></div>', 
    scope: { 
     data: '=', //list of data object to use for graph 
     xkey: '=', 
     ykey: '=' 
    }, 
    link: function(scope,element,attrs){ 
     new Morris.Line({ 
      element: element, 
      data: scope.data, 
      xkey: scope.xkey, 
      ykey: scope.ykey 

     }); 
    } 
    }; 
}); 

你明白了,你可以使它变得复杂,因为你需要它。