我对开发工具中的Sources面板有一个noob问题:在Elements选项卡中,我看到右侧的CSS.我点击一个CSS文件,然后进入Sources选项卡,在那里我可以进行实时编辑.我可以调出JS并执行相同操作,但是......如果我调出HTML文件,我将无法对HTML进行任何编辑.为什么是这样?这是设计的吗?我错过了什么?
我正在尝试使用ui-router resolve来获取一些数据以便在控制器中使用:
$stateProvider
.state('home', {
url: '/',
templateUrl: 'templates/home.html',
controller: 'homeCtrl',
resolve: {
friends: ['$http', function($http) {
return $http.get('api/friends.json').then(function(response) {
return response.data;
})
}]
}
})
Run Code Online (Sandbox Code Playgroud)
这是控制器:
angular.module('app').controller('homeCtrl', ['friends', function(friends) {
this.friends = friends;
}]);
Run Code Online (Sandbox Code Playgroud)
HTML:
<section ng-controller="homeCtrl as home">
<ul>
<li ng-repeat="friend in home.friends">
{{friend.name}} : {{friend.age}}
</li>
</ul>
</section>
Run Code Online (Sandbox Code Playgroud)
我怎样才能让它发挥作用?我得到的错误告诉我定义服务.不太清楚该怎么做.此外,我知道我可以通过注入$ scope来实现它.我希望避免这种情况,因为我正在努力学习新的东西.
使用Ruby中的任何类,并询问某些方法的定义:
Object.method :name
#<Method: Class(Module)#name>
Run Code Online (Sandbox Code Playgroud)
太好了.所以,我可以使用pry或者访问ruby-doc.org并阅读关于Module上定义的:name方法.
我的问题是,这里发生了什么:
Object.method :class
#<Method: Class(Kernel)#class>
Run Code Online (Sandbox Code Playgroud)
我没有看到在内核模块上定义了:class方法.我看到它在Object类上定义.有人可以为我澄清一下吗?