0
我想用我的新角應用Gulp和Browserify。包括使用Gulp(和Browserify)的角度依賴
問題:如何在app.js
中包含角度依賴關係,使其不引發依賴關係錯誤?
我甚至不能讓它不依賴負載,但只能使用$stateProvider
在配置爲:
require('angular'); // It works with a basic declaration, but still gives an error in the browser console - *wierd*
var app = angular
.module('myApp', [
// 'ui-router' I want these to be included as well
])
.config(function ($stateProvider) {
// This will error and say $stateProvider unknown provider
});
我想包括角服務/供應商,如$stateProvider
和$urlRouterProvider
,然後也有新的依賴關係,如'ui.router','ngAnimate','ngResource',...
我知道我必須包括該文件(與鮑爾他們都在index.html
作爲腳本包括涼亭的位置)。我是否鏈接到node_modules
?,將它包含在Gulp?中?既不?,另一個節點模塊npm install ...
?
我的結構:
|- app
|- _css
|- _js
|- controllers *for angular*
|- directives *for angular*
|- factories *for angular*
app.js *main angular js file*
|- _img
|- _css
|- views
|- directiveViews *html specifically for directives*
|- partials *html snippets*
|- node_modules *for npm/node*
...
server.js *for node to launch*
gulpfile.js *for gulp*
其他相關記錄:
- 最終試圖得到一個角度UI路由器的應用程序去。
- 我試圖不使用涼亭,因爲它似乎在它的出路,我想學習與Gulp browserify。
- 我不知道什麼
config.js
(我認爲吞嚥)或如果它需要。 - 我想跟着this教程。
當爲'$ stateProvider'實例化'app'模塊時,您需要在您的依賴項數組中添加'ui.router'。 –
@HuguesStefanski然後我得到'...無法實例化模塊ui.router,原因是: 錯誤:[$ injector:nomod]模塊'ui.router'不可用!你要麼......我如何讓數組引用適當的文件?我還認爲'$ stateprovider'默認包含了angular,但是這可能是我的一個錯誤,因爲我從一開始就一直在使用'ui-router' ...... –
我想我錯過了模塊加載部分,請參閱下面的答案,我認爲它會解決你的問題 –