2
I would like to put in the same file the two functions below, but when I do this, the second function (notebooks
) no longer respond.
Filing cabinet App.js
:
(function () {
'use strict';
var module = angular.module('app', ['onsen']);
module.controller('myCtrl', function ($window, $scope) {
$scope.myFunction = function (item) {
var url = String(window.location);
url = url.substr(0, String($window.location.href).indexOf("www") + 4);
$window.location.href = url + item.mmyurl;
}
});
})();
Another file exemplo.js
:
function NotebookListCtrl($scope) {
$scope.notebooks = [
{"name": "Lenovo",
"procesor": "Intel i5",
"age": 2011},
{"name": "Toshiba",
"procesor": "Intel i7",
"age": 2010},
{"name": "Toshiba",
"procesor": "Intel core 2 duo",
"age": 2008},
{"name": "HP",
"procesor": "Intel core 2 duo",
"age": 2012},
{"name": "Acer",
"procesor": "AMD",
"age": 2006},
{"name": "Lenovo",
"procesor": "Intel i5",
"age": 2009},
{"name": "Toshiba",
"procesor": "Intel i7",
"age": 2008},
{"name": "Lenovo",
"procesor": "Intel i5",
"age": 2011},
{"name": "Toshiba",
"procesor": "Intel i7",
"age": 2010},
{"name": "Toshiba",
"procesor": "Intel core 2 duo",
"age": 2008},
{"name": "HP",
"procesor": "Intel core 2 duo",
"age": 2012},
{"name": "Acer",
"procesor": "AMD",
"age": 2006},
{"name": "Lenovo",
"procesor": "Intel i5",
"age": 2009},
{"name": "Toshiba",
"procesor": "Intel i7",
"age": 2008},
{"name": "Lenovo",
"procesor": "Intel i5",
"age": 2011},
{"name": "Toshiba",
"procesor": "Intel i7",
"age": 2010},
{"name": "Toshiba",
"procesor": "Intel core 2 duo",
"age": 2008},
{"name": "HP",
"procesor": "Intel core 2 duo",
"age": 2012},
{"name": "Acer",
"procesor": "AMD",
"age": 2006},
{"name": "Lenovo",
"procesor": "Intel i5",
"age": 2009},
{"name": "Toshiba",
"procesor": "Intel i7",
"age": 2008}
];
$scope.orderList = "name";
}
I want to merge these two files into one. I’m using the framework Onsen UI.
<body>
<div id="notebooks" ng-app ng-controller="NotebookListCtrl">
<input type="text" id="query" ng-model="query"/>
<select ng-model="orderList">
<option value="name">By name</option>
<option value="-age">Newest</option>
<option value="age">Oldest</option>
</select>
<ul id="notebook_ul">
<li ng-repeat="notebook in notebooks | filter:query | orderBy: orderList">
name: {{notebook.name}}<br/>
procesor: {{notebook.procesor}}<br/>
<div class="right top">{{notebook.age}}</div>
</li>
</ul>
<span>Number of notebooks: {{notebooks.length}}</span>
</div>
<script src='https://ajax.googleapis.com/ajax/libs/angularjs/1.0.7/angular.min.js'></script>
<script src="js/index.js"></script>
</body>
– Leogreen
But some error appears in the console.log?
– celsomtrindade
I’m using visual studio Cordova (template) so it goes right through
– Leogreen
it runs in the browser, da para testar usando o browser e o Notepad
– Leogreen
Yeah, then I won’t know how to help you, because I only work with Angularjs. But the logic of the function is that. Try a console.log($Scope.notebooks); well before you close the controller and see if it pops up the values, which will probably show up. If it does not appear, there must be some error or conflict.
– celsomtrindade
but the project is pure angular js. is only created within the visual studio. removing the files from the ide gets so angular and html. as left in the file
– Leogreen
Ok. But what is it not working exactly? Doesn’t it show the list of notebooks? Doesn’t it do the right order? Try to log as I commented and pass the information later, explaining exactly what is happening
– celsomtrindade
Now gave , kkk discovered the error was worth your help
– Leogreen
Ok. Good luck with development! = D
– celsomtrindade