如何将 underscore.strings 与 AngularJs 一起使用
How to use underscore.strings with AngularJs
我无法让 underscore.strings 使用 AngularJS。
underscore.strings 周围的文档总是显示带有 requireJs 的示例,我认为这不适合 AngularJS。
我无法使用这些语句中的任何一个访问字符串函数,我对如何在没有 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>
试试这个:
https://github.com/floydsoft/angular-underscore
This module exposes underscore's API into angular app's root scope,
and provides some filters from underscore.
结合使用:
尝试使用 s 访问 underscore.string 全局。
使用 _.mixin(s.exports());
整合到下划线中
我无法让 underscore.strings 使用 AngularJS。
underscore.strings 周围的文档总是显示带有 requireJs 的示例,我认为这不适合 AngularJS。
我无法使用这些语句中的任何一个访问字符串函数,我对如何在没有 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>
试试这个:
https://github.com/floydsoft/angular-underscore
This module exposes underscore's API into angular app's root scope, and provides some filters from underscore.
结合使用:
尝试使用 s 访问 underscore.string 全局。
使用 _.mixin(s.exports());