How to place controllers and views in specific directory

39 views
Skip to first unread message

Dave Alex

unread,
Mar 18, 2014, 3:25:36 AM3/18/14
to tot...@googlegroups.com
Hi!
   I am new to total.js. How can I access controllers and views in specific directory.  Like how can I put ADMIN controllers in 'admin' sub-directory of controllers and same process should be in views directory to separate them,

I have created project with following  command:

total -angular

My controller structure is as follows :

exports.install = function (framework){
  framework.route('/bablu', view_bablu);


};


function view_bablu(){
    //var self = this;
    this.view('/bablu/main');


Note : 'bablu' is sub directory in  'views'


When I run it in browser, i get  following error:
500: Internal Server Error


I get following error in console :

--------------------------------------------------------------------
Error: View "/bablu/main" not found. Error: View "/bablu/main" not found.
    at Object.Controller.view500 (E:\nodejs\test\total\angular-01\node_modules\total.js\index.js:4:2
7688)
    at Object.Controller.view (E:\nodejs\test\total\angular-01\node_modules\total.js\index.js:5:1595
)
    at Object.view_bablu (E:\nodejs\test\total\angular-01\controllers\bablu.js:10:10)
    at Subscribe._execute (E:\nodejs\test\total\angular-01\node_modules\total.js\index.js:3:19376)
    at Subscribe.execute (E:\nodejs\test\total\angular-01\node_modules\total.js\index.js:3:17658)
    at Subscribe.prepare (E:\nodejs\test\total\angular-01\node_modules\total.js\index.js:3:18831)
    at Subscribe._end (E:\nodejs\test\total\angular-01\node_modules\total.js\index.js:3:21004)
    at IncomingMessage.EventEmitter.emit (events.js:92:17)
    at _stream_readable.js:920:16
    at process._tickCallback (node.js:415:13)
--------------------------------------------------------------------




Can some one guide me what i am doing wrong and how it can be rectified.

Thanks

Peter Širka

unread,
Mar 18, 2014, 1:27:48 PM3/18/14
to tot...@googlegroups.com
Hi Dave,
the problem is in controller name. Default controller name is routed to /views/ and other controllers are routed by the name, example /views/{controller-name}/.

/controllers/bablu.js ---> /views/bablu/

Example:

function view_bablu(){
   
// views/bablu/main.html
   
this.view('main');
}

Your current action is routed to:

function view_bablu(){
   
// views/bablu/bablu/main.html
   
this.view('/bablu/main');
   
// solution:
   
// this.view('~/bablu/main');
}

Thanks :-)

Reply all
Reply to author
Forward
0 new messages