2015-03-19 53 views
0

如何使用underscore.strings与我有麻烦underscore.strings与AngularJS工作AngularJs

各地underscore.strings的文档始终显示与我不认为是适当的AngularJS requireJs例子。

我不能与任何这些statments的访问字符串函数,我有点困惑于如何我应该没有requirejs初始化underscore.strings

<script src="/bower_components/underscore/underscore.js"></script> 
<script src="/bower_components/underscore.string/dist/underscore.string.js"></script> 

<script type="text/javascript"> 
    $(document).ready(function() { 
     try { 
      console.log(_); // Returns a reference to Underscore 

     } catch (e) { 
      console.log(e); 
     } 
     try { 
      console.log(_s); // Undefined 

     } catch (e) { 
      console.log(e); 
     } 
     try { 
      console.log(_.str); // Undefined 
     } catch (e) { 
      console.log(e); 
     } 
     try { 
      console.log(_.string); // Undefined 
     } catch (e) { 
      console.log(e); 
     } 
    }); 

</script> 

回答

1

尝试使用小号访问underscore.string全球。 整合与_.mixin(s.exports());

0

尝试使用这样的:

https://github.com/floydsoft/angular-underscore

此模块暴露下划线的API成角度应用的根范围, 和从下划线提供一些过滤器。

使用它连同:

https://github.com/epeli/underscore.string

+0

强调你能给身边你如何与underscore.string使用它的一些清晰?我已经能够得到undescore.js工作正常,我也用这个角度下划线连接器https://github.com/andresesfm/angular-underscore-module。我真的不明白,您对例子,如何允许我使用underscore.string? – 2015-03-19 01:59:41

+0

工作了,DCMarkie的答案是什么,我一直在寻找 – 2015-03-19 02:09:05