2015-03-19 29 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